kerryjiang / SuperSocket

SuperSocket is a light weight, cross platform and extensible socket server application framework.
Apache License 2.0
3.95k stars 1.15k forks source link

使用BeginEndMarkPipelineFilter协议,如果发过来的数据不按照协议格式,客户端连接会直接被断开,捕捉不到正确的错误 #559

Open Arthaslcm opened 2 years ago

Arthaslcm commented 2 years ago

我尝试在OnSessionClosedAsync中的CloseEventArgs中获取其 Reason,显示的文本是 RemoteClosing,而实际上,在源码中是通过catch捕捉异常 直接输出日志OnError("Protocol error", e)后就调用Close()方法了。 我想获取到Protocol error这个错误,而不是RemoteClosing,该怎么做? 我觉得源码中在捕捉异常处应该使用await CloseAsync(Channel.CloseReason.ProtocolError)而不是直接Close()

源码位置: SuperSocket\src\SuperSocket.Channel\PipeChannel.cs Line:427

kerryjiang commented 2 years ago

Good catch!

I am fixing it.

kerryjiang commented 2 years ago

Made a fix for it: https://github.com/kerryjiang/SuperSocket/commit/e758bd6ef045e77af1ef534382e71bbefcf3fc08

NowUp commented 2 years ago

通过Nuget的引用,我也遇到了同样的问题,请问该问题被修复了吗?