signalr connection timeout

Jak
Jak
908 Points
132 Posts

Hi,

I am using signalr for signaling. It's working fine but after some time it is stopped.

I got following script error as:

https://domain/signalr/reconnect?transport=serverSentEvents&mes…nAKf9ALd6h&connectionData=%5B%7B%22name%22%3A%22currencyhub%22%7D%5D&tid=5 
Failed to load resource: net::ERR_CONNECTION_TIMED_OUThttps://domain/signalr/reconnect?transport=serverSentEvents&mes…nAKf9ALd6h&connectionData=%5B%7B%22name%22%3A%22currencyhub%22%7D%5D&tid=7
Failed to load resource: net::ERR_CONNECTION_TIMED_OUT

Please help

Views: 17312
Total Answered: 3
Total Marked As Answer: 2
Posted On: 14-Sep-2015 00:31

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
4916 Points
27 Posts
         

Hi Jak,

You can change the connectiontimeout property on application_start as:

protected void Application_Start(object sender, EventArgs e)
{
// Make long polling connections wait a maximum of 110 seconds for a
// response. When that time expires, trigger a timeout command and
// make the client reconnect.
GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110);
 
// Wait a maximum of 30 seconds after a transport connection is lost
// before raising the Disconnected event to terminate the SignalR connection.
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(30);
 
// For transports other than long polling, send a keepalive packet every
// 10 seconds.
// This value must be no more than 1/3 of the DisconnectTimeout value.
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(10);
 
RouteTable.Routes.MapHubs();
}

 

Posted On: 14-Sep-2015 05:24
Brian
Brian
2376 Points
13 Posts
         

Hi Jak,

You can check if a connection timeout occurred on SignalR client script as:

var tryingToReconnect = false;
$.connection.hub.reconnecting(function () {
tryingToReconnect = true;
});
$.connection.hub.reconnected(function () {
tryingToReconnect = false;
});
$.connection.hub.disconnected(function () {
if (tryingToReconnect) {
ShowConnectionTimeoutMessage(); // Your function to notify user.
}
});

 

You can use above code on client script block.

Posted On: 24-Sep-2015 02:29
Priya
Priya
1194 Points
33 Posts
         

Hey guys,

Its really helpful.

Posted On: 29-Apr-2016 08:09
 Log In to Chat