-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Client connection is lost with no obvious reason #174
Comments
Do you have TCP keepalives enabled on either client or server? I don't suspect there is an issue in the implementation, but if you can point to one, I'd love a PR with a fix! |
I have keepalive enabled on the client but not on the test server. I've found another issue where you explain that keepalives can bring odd behavior. I can disable them and see if it helps. It is worth mentioning that I cannot reproduce this issue on my windows pc, and it fails in the ci pipe that executes in a Linux environment (mcr.microsoft.com/dotnet/sdk:6.0-alpine). Therefore, it seems more likely to be something related to keepalives. This issue can be closed, I suppose. And if I find a problem in the library code that I can fix, I'll do a PR as you suggest. Thanks! |
Hi @zllvm TCP keepalives are the bane of my existence (at least with these libraries...). I have unfortunately zero control over them, and they only exist to solve a very niche problem (cable removed from switch or router) and it often doesn't even do a good job of solving that, not to mention they seemingly introduce random problems everywhere. Please let me know if disabling them helps. Please re-open if the problem continues with keepalives disabled! Cheers, Joel |
Hi @jchristn! Aw, I understand your pain! It works much better with keepalives disabled, though it still disconnects occasionally. I started to debug it by increasing logging in your library. It turns out that it fails on: var clientSentData = _client.Client.Receive(buff, SocketFlags.Peek) != 0; with After that, the connection is forcefully closed by If I understand it correctly, Thereby, I realized that I don't fully comprehend the logic in
Likewise, what do you think about configuring the |
I've done the following change in catch (SocketException ex)
{
Logger?.Invoke($"{Header}poll socket from {ServerIpPort} failed with ex = {ex}");
return ex.SocketErrorCode == SocketError.TimedOut;
} After that, I deployed it to the dev server and started a TCP connection that has been up and running for two days with no issues. I could test it by running various commands on the open connection, which worked perfectly. The log entry that I've added Evidently, What is your opinion on this, @jchristn? Could we re-open this issue? |
FYI: We are having the exact same issue in our environment here. |
I work with Energiz0r. |
Hi, I will take a look today. Cheers |
Hi, could you please try v3.0.7? NuGet: https://www.nuget.org/packages/SuperSimpleTcp/3.0.7 |
Please re-open if this doesn't address the issue. Cheers! |
I implemented an integration test that uses TcpClient and TcpServer. This test fails sporadically because the client loses the connection (e.g.,
disconnecting from 127.0.0.1:12345 due to connection lost
) when trying toPollSocket
, though the server is up and running.I've treated this problem by increasing
ConnectionLostEvaluationIntervalMs
so thatPollSocket
is not called. Then the test is passed, and the client communicates correctly with the server.The implementation of PollSocket does not provide an apparent reason for the connection loss:
Thereby, it could be good to include some logging.
I'd like to know if I misunderstood some concepts or if there're flaws in the
PollSocket
implementation?The text was updated successfully, but these errors were encountered: