Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Signalr change connectionId OnReconnected method?

I was wondering if signalr changes the connectionId on OnReconnected method? as I'm mapping a list of users to their connection ids so if the reconneced event raised on the server due to slow connection for example will the connectionId will be changed ?

like image 693
Abdoo.ay Avatar asked Aug 01 '17 00:08

Abdoo.ay


2 Answers

No. The connectionId does not change in an OnReconnected event.

  • The OnReconnected fires automatically(if you're using a signalR client) within the disconnect timeout in case there is a network issue and a keep alive is missed.
  • If the network is disrupted or the server is unable to process the OnReconnected event for longer than the disconnect timeout, the connection will be disconnected on the server and a new connection will need to be made. This making a new connection is not automatic. The client code will have to call a connection.Start() to create a new connection.
  • If the client comes back with the old connectionId, it will not go through as that connection would be in a disconnected state.

So if you are mapping connectionIDs with Users then you need to make sure that the connection Id is updated with the new connectionId in every OnConnected event and deleted in every OnDisconnected event on the server .

like image 70
KRoy Avatar answered Jan 03 '23 07:01

KRoy


I don't believe the OnReconnect will change the connectionID. However, that depends on what the cause of the problem is.

If the client dropped it's internet connection for example and then picked back up, OnReconnect fires and the user should have the same connectionID.

If the server rebooted or IIS restarted, then you have a different situation and when your clients refresh it will appear as a OnConnect and get a new connectionID.

like image 32
Frank M Avatar answered Jan 03 '23 05:01

Frank M