0

Angular: 9,

SignalR: "@microsoft/signalr": "^6.0.0"

//The following code creates and starts a connection
hubConnection: signalR.HubConnection;
this.hubConnection = new signalR.HubConnectionBuilder()
  .withUrl(
    `<url>`)
  .withAutomaticReconnect()
  .build();
this.hubConnection
  .start()
  .then(() => {
    console.log('Connection Started...');
    this.receiveMessageEvent();
  })
  .catch((err) => {
    console.log('Error while starting connection: ' + err);
  });

receiveMessageEvent() {
this.hubConnection.on(
  'receiveMessage',
  (message: any) => {
    console.log(message);
  }
); 
}

getting issue while internet get offline,

Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 (no reason given).'.

Issue: when the internet gets a connection after some minutes of disconnection we need to refresh the screen to connect the hub.

looking for: It should automatically re-connect when the internet gets connected.

How to re-connect hub connection when internet get online?

Mitul
  • 27
  • 1
  • 6
  • Can you please share some more detailed information about your issue: --- "Show some Code" --- "Show what you've already tried (not just this attempt but all of them) and what errors occured" --- "What terms did you use while searching the web regarding this issue" --- "What are you trying to achieve with your program" etc... Also consider formatting your post with a clean and easy to read markup format. – Fy Z1K Feb 20 '22 at 14:11
  • Hi, @FyZ1K I have updated the details. – Mitul Mar 08 '22 at 05:09
  • Error 1006 basically means an abnormal disconnection which is caused by many reasons... It could either be a faulty browser implemenation or a faulty client implementation OR a faulty server configuration. Have you tried it in different browsers? f.e firefox, chrome, edge etc? are they all returning 1006 on a disconnect? And also consider (if possible) to try out different proxy timeout spans as for the most default behaviors it is configured for 60 seconds only, try something like 24h. – Fy Z1K Apr 04 '22 at 13:28

0 Answers0