1
votes

My ASP.NET Web API (target framework: .NET Framework 4.6.2) project frequently loses connection with Azure SignalR service (free tier). I have followed the example as shown in aspnet ‘chatroom’ example.

My client application is based on Angular JS. Messages are being send to the clients but after a few hours, the server connection with Azure SignalR service is lost and is not established again.

As far as I understand from the MS Azure SignalR Internals documentation:

If a server connection is disconnected for network issue,

  • the server connection starts reconnecting automatically.

The following error is returned back in response:

Azure SignalR Service is not connected yet, please try again later

However, this does not seem to be happening i.e. server connection with Azure SignalR service is not established again.

enter image description here

nuget packages:

  • Microsoft.AspNet.SignalR v2.4.0
  • Microsoft.AspNet.SignalR.Core v2.4.0
  • Microsoft.AspNet.SignalR.SystemWeb v2.4.0
  • Microsoft.Azure.SignalR.AspNet v1.0.0-preview1-10317
  • Microsoft.Azure.SignalR.Protocols v1.0.6
2

2 Answers

0
votes

There is currently an issue with Microsoft.Azure.SignalR.AspNet v1.0.0-preview1-10317. The fix is planned to be released this week.

-1
votes

Have you added error handling code in your client like below-

 // Define handlers for any errors
        //
        this.hubConnection.error((error: any) => {
            // Push the error on our subject
            //
            this.hubConnection.start()
                .done(() => {
                    this.startingSubject.next();

                    //Invoke connect method on Hub
                    //  this.hubProxy.invoke("Connect", userId, usertype);

                })
                .fail((error: any) => {
                    this.startingSubject.error(error);
                });
        });

Also in case of closed connection code would be like

this.hubConnection.onclose(() => { 
    setTimeout(function(){
    this.hubConnection.start()
               .done(() => {
                    this.startingSubject.next();

                        //Invoke connect method on Hub
                      //  this.hubProxy.invoke("Connect", userId, usertype);

                   })
                  .fail((error: any) => {
                        this.startingSubject.error(error);
                   });
       },3000); 
   }); 

Hope it helps.

MV