Reputation: 719
My client reconnects every two seconds to the SignalR hub. I'd like to know if thats by design or a mistake by me.
Client:
var connection = new HubConnection("http://xyz.cloudapp.net/push");
connection.Start().Wait();
Server:
var listenUrl = "http://xyz.cloudapp.net/push";
WebApplication.Start<Startup>(listenUrl );
Fiddler-Screenshot
Log (Client, StateChanged Event / HubConnection):
16:20:48 State Changed: Disconnected -> Connecting
16:20:52 State Changed: Connecting -> Connected
16:20:53 State Changed: Connected -> Reconnecting
16:20:53 State Changed: Reconnecting -> Connected
16:20:55 State Changed: Connected -> Reconnecting
16:20:55 State Changed: Reconnecting -> Connected
[...]
Question 1:
What can I do to avoid that every client will call my server every two seconds because of the reconnect?
Question 2: How can I get information about the reconnection "issue"? Is there a way to get some internal logs?
EDIT 1: I've changed the transport to long polling:
connection.Start(new LongPollingTransport()).Wait();
I've found out that by default long polling AND server sent events are used. When I do use only long polling as transport the reconnects do not happen every 2 seconds (now about every minute). But the configuration values (heartbeart, etc) are also not used.
Question 3 How do I set the reconnect time for the long polling transport? I've found a property ReconnectDelay but that do not seem to be the right one.
Upvotes: 3
Views: 2968
Reputation: 11
Thanks to you I solved my problem!
I was getting exceptions of "System.Net.WebException: The request was aborted: The request was canceled" in my SignalR winform client. The solution was to use:
HubConnection conn = new HubConnection(myURL);
conn.Start(**new LongPollingTransport()**).Wait();
instead of
conn.Start().Wait();
Upvotes: 1
Reputation: 719
It was my fault.
I have tried to reproduce the "issue" with a new isolated project. I've found out that my Server Application was using old and outdated SignalR libraries. After updating to the latest it worked flawlessly. David, thanks for your help.
Upvotes: 2