Skip to content

SignalR client hanging on reconnections #63333

@cowlinb6

Description

@cowlinb6

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using Microsoft.AspNetCore.SignalR.Client v9.0.8 we are seeing issues during the reconnection process. If the SignalR connection is lost automatic reconnection is successful most of the time. But occasional it will fail to reconnect and the Hub Connection seems to hang.

Other parts of the application continue as normal and only a restart of the application resolves the issue.

This is running on Debian GNU/Linux 12 (bookworm)
Version: 6.1.0-38-cloud-amd64

From the diagnostic file HubConnection log

07:00:14.4452|DEBUG|Processing 164 byte message from server. 
07:00:15.8458|ERROR|The server connection was terminated with an error. System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
   at System.Net.WebSockets.ManagedWebSocket.ThrowEOFUnexpected()
   at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartReceiving(WebSocket socket)
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.ReceiveLoop(ConnectionState connectionState)
07:00:15.8458|DEBUG|Canceling all outstanding invocations. 
07:00:15.8458|ERROR|Connection is shutting down due to an error. System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
   at System.Net.WebSockets.ManagedWebSocket.ThrowEOFUnexpected()
   at System.Net.WebSockets.ManagedWebSocket.EnsureBufferContainsAsync(Int32 minimumRequiredBytes, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartReceiving(WebSocket socket)
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at Microsoft.AspNetCore.SignalR.Client.HubConnection.ReceiveLoop(ConnectionState connectionState)
07:00:15.8458|DEBUG|Invoking the Closed event handler. 
07:00:25.8554|DEBUG|Starting HubConnection. 
.... No more events from here

From the HttpConnection log

06:59:13.9827|DEBUG|Disposing HttpConnection. 
06:59:13.9853|INFO|HttpConnection Disposed. 
06:59:24.0214|DEBUG|Starting HttpConnection. 
06:59:24.0245|DEBUG|Starting transport 'WebSockets' with Url: https://...
06:59:24.2330|DEBUG|Transport 'WebSockets' started. 
06:59:24.2330|INFO|HttpConnection Started. 
07:00:15.8458|DEBUG|Disposing HttpConnection. 
07:00:15.8458|INFO|HttpConnection Disposed. 
07:00:25.8554|DEBUG|Starting HttpConnection. 
07:00:25.8554|DEBUG|Starting transport 'WebSockets' with Url: https://.... 
... No more events from here

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions