Skip to content

System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. #4740

@khteh

Description

@khteh

Open 2 chrome tabs, start chat, close one of the tabs and obeserve this exception in the log:

[04/21/2025 16:10:47 +08:00] Debug { Id: 14, Name: "ClosedPrematurely" } IP:::1 CorrelationId:null Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 ContentType:null ContentLength:null RequestBody: RequestQuery:?access_token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtaWNrZXkiLCJqdGkiOiIwMTk2NTc2Ni0xODg1LTdmMTgtOGU1Zi01MmQwODNkY2FmMjUiLCJpYXQiOjE3NDUyMjMwMzAsInJvbCI6ImFwaV9hY2Nlc3MiLCJpZCI6IjQ0NjY1MTE4LWVlNjEtNDc5Ny04N2I5LTIyOGY3Zjc4MzI1MCIsIm5iZiI6MTc0NTIyMzAzMCwiZXhwIjoxNzQ1MjMwMjMwLCJpc3MiOiJ3ZWJBcGkiLCJhdWQiOiJodHRwczovL2xvY2FsaG9zdC8ifQ.jD-XgArauL1xrFsTVRKRphxkCixGvG0Yo91a-oXtBHcldzrZ4fliQHB7EqhoEf287EdF5jjcTdx-Jkgfl9thqw MemoryUsage:6066176/415784960 Socket connection closed prematurely. { SourceContext: "Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport", TransportConnectionId: "GpE4isDXAHM2wOpDRQTwbA", RequestId: "0HNC0LFI55B3J:00000029", RequestPath: "/chatHub", ConnectionId: "0HNC0LFI55B3J", ThreadId: 30, ExceptionDetail: [("HResult": -2147467259), ("Message": "The remote party closed the WebSocket connection without completing the close handshake."), ("Source": "System.Net.WebSockets"), ("TargetSite": "Void MoveNext()"), ("InnerException": [("Type": "System.IO.IOException"), ("HResult": -2146232800), ("Message": "The client reset the request stream."), ("Source": "System.Private.CoreLib"), ("TargetSite": "Void Throw()")]), ("ErrorCode": 0), ("WebSocketErrorCode": ConnectionClosedPrematurely), ("NativeErrorCode": 0), ("Type": "System.Net.WebSockets.WebSocketException")], X_Original_For: null, X_Forwarded_Proto: null, X_Original_Proto: null, X_Forwarded_Host: null, X_Original_Host: null } 
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
 ---> System.IO.IOException: The client reset the request stream.
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2MessageBody.ReadAsync(CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at System.Net.WebSockets.ManagedWebSocket.ReceiveAsyncPrivate[TResult](Memory`1 payloadBuffer, CancellationToken cancellationToken)
   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.Internal.Transports.WebSocketsServerTransport.StartReceiving(WebSocket socket)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions