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

Preventing disconnection due to network inactivity #42

Open
abulava opened this issue May 27, 2020 · 1 comment
Open

Preventing disconnection due to network inactivity #42

abulava opened this issue May 27, 2020 · 1 comment

Comments

@abulava
Copy link

abulava commented May 27, 2020

I had a frustrating experience with running a net-http2 client on Azure VM. When the client is idle for about 240 seconds, Azure infrastructure will silently drop "outbound SNAT". As a result, I get the :error callback with Errno::ETIMEDOUT in 15 minutes after the async request.

A reply from Azure support confirmed that I was right about my idea to tune the TCP keepalive settings like sysctl -w net.ipv4.tcp_keepalive_time=120. Unfortunately, net-http2 was not affected by this tuning.

I found that net-http2 simply doesn't set the specific socket option SO_KEEPALIVE, which is necessary for TCP keepalive. So, I forked the net-http2 and applied a band aid.

@abulava
Copy link
Author

abulava commented May 27, 2020

Sure, my solution is not good. A quote from TCP Keepalive HOWTO:

The most beautiful thing you can do when writing an application is to make it as customizable as possible, and not to force decisions. If you want to consider the happiness of your users, you should implement keepalive and let the users decide if they want to use it or not by using a configuration parameter or a switch on the command line.

I think that a proper solution should add new options to NetHttp2::Client.new for enabling TCP keepalives and tuning their settings at a socket level with SOL_TCP TCP_KEEPIDLE/TCP_KEEPINTVL/TCP_KEEPCNT (these options would allow to keep system-wide sysctl settings intact).

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

1 participant