The reason might be because your OnReconnect
even doesn't fire and then again your OnDisconnected
doesn't fire when the client calls the `stop method as described here:
If the client goes into reconnecting mode but can't establish a
transport connection within the disconnect timeout limit, the server
terminates the SignalR connection. When that happens, the server
executes the Hub's OnDisconnected method and queues up a disconnect
message to send to the client in case the client manages to connect
later. If the client then does reconnect, it receives the disconnect
command and calls the Stop method. In this scenario, OnReconnected is
not executed when the client reconnects, and OnDisconnected is not
executed when the client calls Stop.
This is referring to SignalR version 2, But I believe that it will of help to you as well.
Worth mention as well, that you will contentiously try to reconnect if you call start
from your closed
event (or disconnect
in JavaScript`) as said:
In some applications you might want to automatically re-establish a
connection after it has been lost and the attempt to reconnect has
timed out. To do that, you can call the Start method from your Closed
event handler (disconnected event handler on JavaScript clients). You
might want to wait a period of time before calling Start in order to
avoid doing this too frequently when the server or the physical
connection are unavailable. The following code sample is for a
JavaScript client using the generated proxy.
anyway, the simplest way to disconnect your client from the server up until version 2 is to implement the disconnect
method on the client an call it from the server as mentioned:
SignalR version 2 does not have a built-in server API for
disconnecting clients. There are plans for adding this functionality
in the future. In the current SignalR release, the simplest way to
disconnect a client from the server is to implement a disconnect
method on the client and call that method from the server.