Giter Site home page Giter Site logo

Comments (14)

jchristn avatar jchristn commented on May 9, 2024

Hi, you may have to build a method that periodically sends a heartbeat message. I haven't found TCP keepalives to be completely reliable on all platforms, especially when there may be intermediary devices.

What OS are you using for client and server? Which framework/runtime are you using?

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Hi, you may have to build a method that periodically sends a heartbeat message. I haven't found TCP keepalives to be completely reliable on all platforms, especially when there may be intermediary devices.

What OS are you using for client and server? Which framework/runtime are you using?

I'm using Windows for server and client. The Server is a Windows Forms App (.Net Framework 4.7.2), the Client is a WPF Application (also .Net Framework 4.7.2)

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

How often should this heartbeat method been called? I have a method on server that send all 50ms data to all clients and also a method on client site that sends all 50ms data to the server (if something changed)

from supersimpletcp.

jchristn avatar jchristn commented on May 9, 2024

Hi @w123u567 I would start with something around 10 seconds. An alternative would be to use Wireshark on the client and server and see if a TCP reset is being sent from one side to the other, or from an intermediary device. Cheers, Joel

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Thank you, I will try this.

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Wireshark shows the following output:
image

It seems like the server sends a TCP reset to the client, but I don't understand why.

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

I also implemented a method that sends every few seconds data (on client and on server), but nothing changed.

from supersimpletcp.

jchristn avatar jchristn commented on May 9, 2024

Could you try setting _server.Keepalive.EnableTcpKeepAlives = false; and the same thing on the client, and see what happens? All of the TCP keepalive functionality is buried within the kernel - the properties I provide simply set them using the exposed APIs, and anecdotally, they aren't the most reliable.

from supersimpletcp.

jchristn avatar jchristn commented on May 9, 2024

Also the 'spurious retransmissions' may be of concern - it indicates that Wireshark has already seen the ACK, but perhaps the ACK was not received by the sender.

Are your client and server on the same LAN segment, i.e. there's no router in between them (other than perhaps a WiFi router)?

https://www.chappell-university.com/post/spurious-retransmissions-a-concern

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Could you try setting _server.Keepalive.EnableTcpKeepAlives = false; and the same thing on the client, and see what happens? All of the TCP keepalive functionality is buried within the kernel - the properties I provide simply set them using the exposed APIs, and anecdotally, they aren't the most reliable.

I tried this and at the moment it's running since a few minutes without disconnecting. Maybe this was the solution. Also no 'spurious retransmissions' are shown in WireShark.

from supersimpletcp.

jchristn avatar jchristn commented on May 9, 2024

Got it. Well, let's hope that fixes the issue for you! I was tempted to leave TCP keepalives out of all of my TCP libraries since it's really like dark voodoo magic that happens under the hood, and no controls/notifications are provided when the kernel takes action. Would you mind keeping me updated on how it looks after some time? Cheers, Joel

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Also the 'spurious retransmissions' may be of concern - it indicates that Wireshark has already seen the ACK, but perhaps the ACK was not received by the sender.

Are your client and server on the same LAN segment, i.e. there's no router in between them (other than perhaps a WiFi router)?

https://www.chappell-university.com/post/spurious-retransmissions-a-concern

If I use the client in the same Network everything was fine, only if I connect from outside of my private network (port forwarding is set correctly)

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

Got it. Well, let's hope that fixes the issue for you! I was tempted to leave TCP keepalives out of all of my TCP libraries since it's really like dark voodoo magic that happens under the hood, and no controls/notifications are provided when the kernel takes action. Would you mind keeping me updated on how it looks after some time? Cheers, Joel

Yes, I hope it will work now. I will do some tests and let you know if the problem is fixed. Thank you very much for the support :) 👍

from supersimpletcp.

w123u567 avatar w123u567 commented on May 9, 2024

No more unwanted disconnects since I set _server.Keepalive.EnableTcpKeepAlives = false;. I will close this issue and hope for the best :)

from supersimpletcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.