Last post Apr 01, 2017 07:10 AM by Zhi Lv - MSFT
Feb 08, 2017 04:59 PM|osmiumbin|LINK
Hello, i'm facing the following problem:
Setup: Self hosted SignalR server (console) + web client application.
i assume, since the js is not running in this time) but after that if i continue the client execution i am able to call server hub methods from the already 'terminated' connection. Is this normal? How can i prevent that from happening after the OnDisconnected
event fired? I was expecting the connection to be disposed and the request to never reach the server prior to starting a new connection.
error. Please let me know if this is a known issue or how can i fix it?
Feb 09, 2017 09:45 AM|Zhi Lv - MSFT|LINK
Perhaps it re-connect, you could call the stop() method to stop the connection. More details, I suggest you take a look at this article to check the Connection Lifetime Events in SignalR.
Feb 10, 2017 05:38 PM|osmiumbin|LINK
Hello Zhi Lv,
Thanks for the reply. For some strange reason i cannot reproduce the issue anymore. What i get now is that while the JS is paused in the browser the connection is not lost so the server OnDisconnected is not called. After resuming the JS, all the requests
that were supposed to go to the server are sent (probably queued?) and if the pause took more than the disconnect timeout, it closes the client connection so any other request cannot go through anymore. On the server, after the disconnect timeout, the OnDisconnected
method is called (stopCalled = false) and the connection is terminated on the server side. No reconnection will happen though. So in this case the total time needed to terminate the connection on the server side is JS pausing time + disconnect timeout (default
I was expecting that the connection to be terminated on the server during the debugging period since the JS execution is paused (therefore unresponsive), but i guess that's not an issue.
Apr 01, 2017 07:10 AM|Zhi Lv - MSFT|LINK
How can i prevent that from happening after the OnDisconnected event fired?
As far as I know, SignalR version 2 does not have a built-in server API for disconnecting clients or preventing clients from calling hub methods. If you’d like to prevent clients from calling hub methods after the OnDisconnected event fired, you could try
to define a function and call $.connection.hub.stop() on the client, and then you could call that function from the server to stop a connection.