SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

HubConnection.Error handler is not called on connection error

Open igolets opened this issue 2 years ago • 0 comments

I'm using package id="Microsoft.AspNet.SignalR.Client" version="2.4.3" targetFramework="net48". Using Azure SignalR service with backend deployed as Azure WebApp.

Steps to reproduce

  1. App connects to server, reach "Connected" state
  2. Client subscribed to Closed, StateChanged, Error events. Error event handler suppress all exceptions.
  3. Shut down WebApp.
  4. Run Connection.Start() from Closed event handler

Expected behavior

  1. StateChanged (Connected -> Reconnecting)
  2. Error ("Unable to connect to remote server")
  3. Error ("Couldn't reconnect within the configured timeout of 00:00:05, disconnecting.")
  4. StateChanged (Reconnecting -> Disconnected)
  5. Closed()
  6. Restart by calling connection.Start()
  7. Repeat until connection is back.

Actual behavior

  1. StateChanged (Connected -> Reconnecting)
  2. Error ("Unable to connect to remote server")
  3. Error ("Couldn't reconnect within the configured timeout of 00:00:05, disconnecting.")
  4. StateChanged (Reconnecting -> Disconnected)
  5. Closed()
  6. Restart by calling connection.Start()
  7. After repeating this several times I get unhandled exception.

Exception type: Microsoft.AspNet.SignalR.Client.HttpClientException

Source: Microsoft.AspNet.SignalR.Client

Exception message: StatusCode: 403, ReasonPhrase: 'Site Disabled', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Connection: close Date: Tue, 26 Sep 2023 15:06:55 GMT Content-Length: 2342 Content-Type: text/html }

Stack trace: at Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient.<>c__DisplayClass5_0.<Get>b__1(HttpResponseMessage responseMessage) at Microsoft.AspNet.SignalR.TaskAsyncHelper.<>c__DisplayClass31_02.<Then>b__0(Task1 t) at Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners2.<>c__DisplayClass3_0.<RunTask>b__0(Task1 t)

igolets avatar Sep 26 '23 15:09 igolets