My application is working under corporate network (ugly proxies and stuff). And it does not work very well. I hoped using https would help but it did not. Here is a weird pattern I see in the logs:
[14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Client subscribed to hub 'modemshub'.
[14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionToken=6aktO0sramoQKhQ9DC7Cs7EbXMUou8LooQRxfup4R0oZCHpBmWBFjyLup%2F3wJLloR8GtJEiUk10YOZJBaSqN8aiGAfXRR4G9hujTFTyiJiz%2FyJ4oMlBIdxqeCc5anI6k&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'.
[14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: longPolling transport starting.
[14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Opening long polling request to 'https://example.com/signalr/connect?transport=longPolling&clientProt…rlCzGHl5kVLClT5ex8&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'.
[14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: Long poll complete.
[14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: LongPolling connected.
[14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: longPolling transport connected. Initiating start request.
[14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: Opening long polling request to 'https://example.com/signalr/poll?transport=longPolling&clientProtoco…rlCzGHl5kVLClT5ex8&connectionData=%5B%7B%22name%22%3A%22modemshub%22%7D%5D'.
[14:13:33 GMT+0600 (N. Central Asia Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
[14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Long poll complete.
[14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Stopping connection.
[14:13:38 GMT+0600 (N. Central Asia Standard Time)] SignalR: Fired ajax abort async = true.
So the connection is established and 5 seconds later it is aborted (while ConnectionTimeout equals to 110 seconds). And this pattern is repeated again and again. That's just weird.
Background
According to Asp.net :
Troubleshooting
Note that SignalR 2.1 introduced keep-alives for long polling. This could be problematic if something is interfering with chunked HTTP responses. If you want to
disable
keepalive
functionality, setKeepAlive
tonull
.Keepalive
functionality is automaticallydisabled
for the long polling transport.If you're using a Self-Host, use the followings with 3 args instead:
As a different alternatives to support a keep alive "like" feature for long polling, Create a server method name it
Ping
:Then, on the client create an interval in which you will
Ping
the server:I hope to be useful.
Assume the tips available in Understanding and Handling Connection Lifetime Events in SignalR where you can employ good solutions to handle connection lifetime based on the network problem. Furthermore, In SignalR's issues I found the following solution for you which works with long-polling too.
You can set the KeepAlive property on the ConfigurationManager and SignalR will send an empty frame of data (based on the transport) on the specified interval to keep the connection alive (look at Allow host to specify keep alive times). The current time-out mechanism makes the streaming protocols no different.
Seems like this behaviour is caused by a bug in SignalR 2.1. There was a similar bug reported: https://github.com/SignalR/SignalR/issues/3557 So we downgraded SignalR to 2.0.3 and this behaviour disappeared.