ng2-signalr icon indicating copy to clipboard operation
ng2-signalr copied to clipboard

Reconnecting question

Open tolvaly opened this issue 6 years ago • 5 comments

I have 2 questions regarding reconnect

  1. If the first connect fails, no more reconnects are made automatically. Can we enable auto reconnect on connect failure?

  2. If the connection interrupts, the client will try for 10 times to reconnect. If even the last reconnect fails, the state sets to disconnect and doesn't try to reconnect any more. Is there any possibility to set this limit to infinite?

tolvaly avatar May 15 '18 11:05 tolvaly

Not sure if this helps but we've implemented a custom retry. This is over simplified but basically, we listen for connection status, on error we delay, and then call connection start again. This allows us to create any retry logic we want.

matthew-valenti avatar Jun 01 '18 06:06 matthew-valenti

Our solution was very similar to your solution. I just asked if there is any built-in option which was forgotten from the wiki

tolvaly avatar Jun 01 '18 07:06 tolvaly

Hi, I am sorry to ask but I would like to know if this would be something like this:

signalR.connect().then(r => { this.connection = r; this.connection.status.subscribe((s: ConnectionStatus) => { if (s.value === 4) { this.connection.start(); } }); });

I

andmaltes avatar Nov 06 '19 18:11 andmaltes

Sorry, I don't remember our solution, it's a really old thread. This solution what you wrote could work.

tolvaly avatar Nov 07 '19 14:11 tolvaly

Hi, I am sorry to ask but I would like to know if this would be something like this:

signalR.connect().then(r => { this.connection = r; this.connection.status.subscribe((s: ConnectionStatus) => { if (s.value === 4) { this.connection.start(); } }); });

I

yes works fine but uses the another signalr connection id while establishing new connection

Vasanthvivi avatar Oct 03 '21 14:10 Vasanthvivi