C
C#2w ago
Salakhosh

Help in understanding a concept in SignalR

Hey guys i am currenlty working with signal R (new to it) and i have a question. I have ClientTimeoutInterval to 30 seconds and KeepAliveInterval 15 second. what i am noticing is if i disconnect (remove lan cable), OnDisconnectAsync() gets called around second 16 and when i reattach lan cable (before 30 seconds timeout) it reconnects and connection stays alive. this is causing me confusion can someone please explain what is going on ? Thanks in advance
4 Replies
Lex Li
Lex Li2w ago
I believe Microsoft documented the timeout values (and other technical details) very well in this old article, https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/handling-connection-lifetime-events So you might spend some time on it.
Understanding and Handling Connection Lifetime Events in SignalR
This article describes how to use the events that are exposed by the Hubs API.
Salakhosh
SalakhoshOP2w ago
Yes sir i read this document yesterday and this part caused me confusion : The OnDisconnected event handler executes at the end of a SignalR connection. A SignalR connection can end in any of the following ways: 1-If the client calls the Stop method, a stop message is sent to the server, and both client and server end the SignalR connection immediately. 2-After connectivity between client and server is lost, the client tries to reconnect and the server waits for the client to reconnect. If the attempts to reconnect are unsuccessful and the disconnect timeout period ends, both client and server end the SignalR connection. The client stops trying to reconnect, and the server disposes of its representation of the SignalR connection. 3-If the client stops running without having a chance to call the Stop method, the server waits for the client to reconnect, and then ends the SignalR connection after the disconnect timeout period. If the server stops running, the client tries to reconnect (re-create the transport connection), and then ends the SignalR connection after the disconnect timeout period. here it says only when client fails to reconnect and disconnect timeout period ends the ondisconnect period executes but in my case it is getting executed before the TimeoutPeriod
Lex Li
Lex Li2w ago
So did you examine the connection IDs?
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?