mgravell / Pipelines.Sockets.Unofficial

.NET managed sockets wrapper using the new "Pipelines" API
Other
400 stars 51 forks source link

Exceptions. #42

Closed juliolitwin closed 4 years ago

juliolitwin commented 4 years ago

Hi,

I am having a problem when clients disconnect from server. I am using my own server, but happens same in sillyousu project.

Repo: https://github.com/sillyousu/TryoutPipelineSockets

The client is basic, I just created a client that creates some connections(like 1000) and sends some packets.

When I just close or stop debugging, several exceptions occur and end up making the server quite slow (like pause).

[22:08:08,840] Connection will be disconnected, because of an exception
Pipelines.Sockets.Unofficial.ConnectionResetException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at Pipelines.Sockets.Unofficial.Internal.Throw.Socket(Int32 errorCode) in C:\********************\Internal\Throw.cs:line 59
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.<GetResult>g__ThrowSocketException|10_0(SocketError e) in C:\********************\SocketAwaitableEventArgs.cs:line 86
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.GetResult() in C:\********************\SocketAwaitableEventArgs.cs:line 79
   at Pipelines.Sockets.Unofficial.SocketConnection.DoReceiveAsync() in C:\********************\SocketConnection.Receive.cs:line 64
   --- End of inner exception stack trace ---
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at TestPipe.Network.PacketPipeReaderBase.ReadBuffer() in C:\********************\PacketPipeReaderBase.cs:line 69
   at TestPipe.Network.PacketPipeReaderBase.ReadSource() in C:\********************\PacketPipeReaderBase.cs:line 48
[22:08:08,840] Connection will be disconnected, because of an exception
Pipelines.Sockets.Unofficial.ConnectionResetException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at Pipelines.Sockets.Unofficial.Internal.Throw.Socket(Int32 errorCode) in C:\********************\Internal\Throw.cs:line 59
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.<GetResult>g__ThrowSocketException|10_0(SocketError e) in C:\********************\SocketAwaitableEventArgs.cs:line 86
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.GetResult() in C:\********************\SocketAwaitableEventArgs.cs:line 79
   at Pipelines.Sockets.Unofficial.SocketConnection.DoReceiveAsync() in C:\********************\SocketConnection.Receive.cs:line 64
   --- End of inner exception stack trace ---
   at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at TestPipe.Network.PacketPipeReaderBase.ReadBuffer() in C:\********************\PacketPipeReaderBase.cs:line 69
   at TestPipe.Network.PacketPipeReaderBase.ReadSource() in C:\********************\PacketPipeReaderBase.cs:line 48

PacketPipeReaderBase original code can be found here (thanks @MUnique): https://github.com/MUnique/OpenMU/blob/master/src/Network/PacketPipeReaderBase.cs

Am I forgetting something?

Thanks!