Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host #163

Open
prajilal opened this issue Oct 25, 2019 · 4 comments

Comments

@prajilal
Copy link

Hello,

I am using a WebSocket client and experiencing Error event with the following message after sending data continuous for 5 minutes:

System.IO.IOException: Unable to write data to the transport connection: 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 System.Net.Sockets.Socket.EndSend(IAsyncResult asyncResult)
at System.Net.Sockets.NetworkStream.EndWrite(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.Security._SslStream.EndWrite(IAsyncResult asyncResult)
at System.Net.Security.SslStream.EndWrite(IAsyncResult asyncResult)
at SuperSocket.ClientEngine.AuthenticatedStreamTcpSession.OnWriteComplete(IAsyncResult result)

Do you know what may be triggering it?

Note: I have connected to the same server using a JavaScript socket client application and no such issues experienced even after 2 hours.

@kerryjiang
Copy link
Owner

It looks like a certificate handshake failure?

@prajilal
Copy link
Author

Seems not, as it works for some time.

@jlnunez89
Copy link

I'm sort of experiencing the same thing. Mine can run for hours before it hits it. I haven't been able to pinpoint why it seemingly randomly disconnects. I do not own the server though, so it's hard to tell why they're severing the connection on their end. Could it maybe pertain to auto ping?

I'm using:
EnableAutoSendPing = true,
AutoSendPingInterval = 60, // in seconds.

@Breno94re
Copy link

Kinda late to the party, but i know where the problem lies.

for some reason, the Websocket buffer isn't dynamic. Its just reaches it limits after a while... i dont have any ideas why. I noticed that if i'm sending bigger files like images from the client to the server, it wont even work without getting the server buffer to higher numbers. And even at higher numbers, it will "explode" at certain point.

To fix that, the "receive buffer" cant be a declared outside the "listening" block, it has to be set at every new message to the server, otherwise you will be disconnected due to buffer going off-limits..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants