Be careful about OnDisconnected when using SignalR

Posted on

If you are using SignalR for your real-time communication, be careful about OnDisconnected virtual method, because there are two different implementations.

1 – It is fired only when connection was closed gracefully (not every time!):

public virtual Task OnDisconnected()

2 – It is fired every time when connection closes:

public virtual Task OnDisconnected(bool stopCalled)

So I recommend to use second version.

Leave a Reply

Your email address will not be published.