Reputation: 438
We deployed to a local development server and SOME users (not all) experience a signalr problem where the serverSentEvents won't connect and it falls back to long polling... normally that would be fine but it takes 5 seconds to fall back and the user experience is horrible.
The request gets a status of "canceled" in chrome's developer tools network tab and we ultimately end up connecting using signalr's longPolling. Here's the logging from signalr:
[16:09:28 GMT-0500 (Eastern Standard Time)] SignalR: Client subscribed to hub 'chat'. jquery.signalR-2.0.0.js:75
[16:09:28 GMT-0500 (Eastern Standard Time)] SignalR: Negotiating with '/signalr/negotiate?connectionData=%5B%7B%22name%22%3A%22chat%22%7D%5D&clientProtocol=1.3'. jquery.signalR-2.0.0.js:75
[16:09:28 GMT-0500 (Eastern Standard Time)] SignalR: Attempting to connect to SSE endpoint 'http://mysubdomain.mydomain.com/signalr/connect?transport=serverSentEvents&con…bYUr2xEEBuw%3D%3D&connectionData=%5B%7B%22name%22%3A%22chat%22%7D%5D&tid=6'. jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: serverSentEvents timed out when trying to connect. jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: EventSource calling close(). jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: This browser supports SSE, skipping Forever Frame. jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: Opening long polling request to 'http://mysubdomain.mydomain.com/signalr/connect?transport=longPolling&connecti…bYUr2xEEBuw%3D%3D&connectionData=%5B%7B%22name%22%3A%22chat%22%7D%5D&tid=2'. jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: Long poll complete. jquery.signalR-2.0.0.js:75
[16:09:33 GMT-0500 (Eastern Standard Time)] SignalR: LongPolling connected.
Once the client is finally connected via long polling, the site works fine but I still need to figure out why serverSentEvents is not working.
I can just disable serverSentEvents to get around this but it works for some people and not others so I'm wondering if there's some way to find out why it's failing for some people and not others.
Any advice on how to diagnose this?
Upvotes: 3
Views: 2168
Reputation: 15234
It is taking 5 seconds to fallback from the Server-Sent Events transport because that is SignalR's default TransportConnectTimeout. This TimeSpan can be shortened via GlobalHost.Configuration.TransportConnectTimeout
at app start.
There are many reasons SSE might fail. For example, there might be a router or firewall between your SignalR server and client that is coalescing or closing the chunked HTTP response that the Server-Sent Events transport relies on. It is difficult to know for sure what the exact cause of the SSE problem is when all I know is that the connection timed out.
Upvotes: 3