HubConnection.Error handler is not called on connection error
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
- App connects to server, reach "Connected" state
- Client subscribed to Closed, StateChanged, Error events. Error event handler suppress all exceptions.
- Shut down WebApp.
- Run Connection.Start() from Closed event handler
Expected behavior
- StateChanged (Connected -> Reconnecting)
- Error ("Unable to connect to remote server")
- Error ("Couldn't reconnect within the configured timeout of 00:00:05, disconnecting.")
- StateChanged (Reconnecting -> Disconnected)
- Closed()
- Restart by calling connection.Start()
- Repeat until connection is back.
Actual behavior
- StateChanged (Connected -> Reconnecting)
- Error ("Unable to connect to remote server")
- Error ("Couldn't reconnect within the configured timeout of 00:00:05, disconnecting.")
- StateChanged (Reconnecting -> Disconnected)
- Closed()
- Restart by calling connection.Start()
- 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)