2

I'm using SignalR 0.5.3 with hubs and I'm explicitely setting transport to long polling like this:

$.connection.hub.start({ transport: 'longPolling' }, function () {
    console.log('connected');
});

with configuration like this (in global.asax.cs Application_Start method):

GlobalHost.DependencyResolver.UseRedis(server, port, password, pubsubDB, "FooBar");
GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(2);
GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(15);

However the long polling doesn't seem to be working neither on development (IIS express) nor on production (IIS 7.5) environment. Connection seems to be made properly, however the long poll request is always timed out (after ~2 minutes) and reconnect happens afterwards. Logs from IIS are here. Response from first timed out request:

{"MessageId":"3636","Messages":[],"Disconnect":false,"TimedOut":true,"TransportData":{"Groups":["NotificationHub.56DDB6692001Ex"],"LongPollDelay":0}}

Timed out reconnect responses looks like this:

{"MessageId":"3641","Messages":[],"Disconnect":false,"TimedOut":true,"TransportData":{"Groups":["NotificationHub.56DDB6692001Ex"],"LongPollDelay":0}}

I would appreciate any help regarding this issue. Thanks.

Edit

If reconnect means the beginning of a new long poll cycle why it is initiated after ~2 minutes when KeepAlive setting in global.asax.cs is set to 15 seconds? Problem with this is that I have a reverse proxy in front of IIS which timeouts keep-alive requests after 25 seconds therefore I get 504 response when this reverse proxy timeout is reached.

yojimbo87
  • 65,684
  • 25
  • 123
  • 131
  • I'm not sure what the problem is you're describing. The timeout happens when you don't get response and is totally by design. What's the issue? – davidfowl Oct 21 '12 at 00:43
  • @dfowler: So the reconnect means the beginning of a new long poll cycle? Why is it timed out after ~2 minutes when I set KeepAlive setting to 15 seconds? See updated question. – yojimbo87 Oct 21 '12 at 07:57
  • Keep alive doesn't work for longpolling (it doesn't make sense). LongPolling waits for 2 minutes by default and you can extend that to be whatever works in your environment. I'm still not understanding the problem. Are you just asking how it works? – davidfowl Oct 21 '12 at 08:01
  • If you need to change the timeout interval to something below 25 seconds then set the timeout. – davidfowl Oct 21 '12 at 08:02
  • @dfowler: Which timeout do you mean I need to set? ConnectionTimeout in signalr configuration? – yojimbo87 Oct 21 '12 at 08:15
  • I just had this exact same issue. Didn't realise my reverse proxy had a timeout. Increased and now working :-) – Lee.Winter Jul 15 '16 at 11:08

2 Answers2

5

Take a look at this post: How signalr works internally. The way long pulling works is after a set time the connection will timeout or receive a response and repull (reconnect)

Community
  • 1
  • 1
Colin Swelin
  • 841
  • 7
  • 7
0

Keep alive functionality is disabled for long polling. Seems that ConnectionTimeout is used instead.

This setting represents the amount of time to leave a transport connection open and waiting for a response before closing it and opening a new connection. The default value is 110 seconds.

https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/handling-connection-lifetime-events#timeoutkeepalive

If the request is timed out and server is not sending any data, but you expect it to send, maybe it is some issue on the server side that you don't yet see.

CodeSamurai
  • 623
  • 3
  • 6