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

Add Timeout in AddRoute #230

Open
martinste1n opened this issue Jul 4, 2024 · 2 comments
Open

Add Timeout in AddRoute #230

martinste1n opened this issue Jul 4, 2024 · 2 comments

Comments

@martinste1n
Copy link

Hi,

first up thank you for this library! We really appreciate your efforts!

We make use of it through the AdsToJava project. Here we face an issue of deadlocks when trying to add a route to a machine that is not available (anymore).

Our specific problem is described in an issue there:
Beckhoff/AdsToJava#10 (comment)

Would it be possible to add a timeout, so that the call will be terminated if the machine is not available?

Thanks in advance!
Martin

Relevant point in source code:

long AmsRouter::AddRoute(AmsNetId ams, const std::string& host)

@pbruenn
Copy link
Member

pbruenn commented Jul 4, 2024

Well, this sounds like a general TCP settings:
/proc/sys/net/ipv4/tcp_syn_retries
/proc/sys/net/ipv4/tcp_synack_retries
read: http://willbryant.net/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout

The problem is most firewalls are configured to silently drop packets to closed ports or missing hosts. So your TCP stack is forced to retry. Which makes these connects appear to take forever. E.g. when I configure my pf firewall to reply with icmp on closed ports block return in inet proto tcp from any to any port 48898 AddRoute will return immediately.

Since you mentioned a deadlock, make sure you have the latest version. We had a lock in the AddRoute facility until a few month ago: 8e8fb2a

@martinste1n
Copy link
Author

Thank you very much... It seems pretty promising that commit 8e8fb2a could solve our problem! Will have a look at it!

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

2 participants