LagrangeDev / Lagrange.Core

An Implementation of NTQQ Protocol, with Pure C#, Derived from Konata.Core
GNU General Public License v3.0
1.96k stars 238 forks source link

[Bug?]: 正向ws断连导致的报错, 或者是吞消息? #457

Closed Cjsah closed 1 month ago

Cjsah commented 2 months ago

请确保您已阅读以上注意事项,并勾选下方的确认框。

Lagrange项目

OneBot

所使用/依赖的Lagrange项目对应的commit

latest

运行环境

Linux

运行架构

x64

连接方式

正向 WebSocket

重现步骤

第三方 反复连接断开websocket

期望的结果是什么?

正常运行, 消息正常处理

实际的结果是什么?

虽然没有崩溃, 但没法接收新的消息

fail: Lagrange.OneBot.Core.Network.Service.ForwardWSService[995]
      ReceiveException(38b43a8d-9325-4992-9238-36f04f205b12)
      System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake.
       ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer.
       ---> System.Net.Sockets.SocketException (104): Connection reset by peer
         --- End of inner exception stack trace ---
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
         at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
         at System.IO.Stream.ReadAtLeastAsyncCore(Memory`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream, CancellationToken cancellationToken)
         at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
         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.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 System.Threading.Tasks.ValueTask`1.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
      --- End of stack trace from previous location ---
         at Lagrange.OneBot.Core.Network.Service.ForwardWSService.ReceiveAsyncLoop(String identifier, CancellationToken token)
�fail: Lagrange.OneBot.Core.Network.Service.ForwardWSService[992]
      LogDisconnectException(38b43a8d-9325-4992-9238-36f04f205b12)
      System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('Aborted') for this operation. Valid states are: 'Open, CloseReceived, CloseSent'
         at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates)
         at System.Net.WebSockets.ManagedWebSocket.CloseAsync(WebSocketCloseStatus closeStatus, String statusDescription, CancellationToken cancellationToken)
      --- End of stack trace from previous location ---
         at Lagrange.OneBot.Core.Network.Service.ForwardWSService.DisconnectAsync(String identifier, WebSocketCloseStatus status, CancellationToken token)

简单的复现代码/链接(可选)

No response

Trace 级别日志记录(可选)

No response

补充说明(可选)

搜到了一个问题几乎一模一样的反向ws问题: #153

Cjsah commented 2 months ago

感觉更像是 #426

kKsk03 commented 1 month ago

确实疑似有这个问题 不知道和正向ws有没有关系 总之时不时就噶了 过段时间又好了 挺奇怪

ghost commented 1 month ago

报错显示连接被对端重置,请配上对端的日志