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

fix: don't set TCP keepalive on listening sockets #709

Merged
merged 1 commit into from
May 30, 2022
Merged

Conversation

blckngm
Copy link
Contributor

@blckngm blckngm commented May 30, 2022

On Mac OS X, it causes the listening socket to be “closed” after the
keepalive timeout and future connections to fail with “connection
refused” errors. We suspect the same may happen on linux in some
circumstances because we see similar errors in CI.

For hyper, we switch to use AddrIncoming::set_keepalive. It sets TCP
keepalive options on sockets returned by accept instead of on the
listening socket.

Tentacle unfortunately does not seem to allow setting options on
accepted sockets, so TCP keepalive setting is removed for now.

On Mac OS X, it causes the listening socket to be “closed” after the
keepalive timeout and future connections to fail with “connection
refused” errors. We suspect the same may happen on linux in some
circumstances because we see similar errors in CI.

For hyper, we switch to use `AddrIncoming::set_keepalive`. It sets TCP
keepalive options on sockets returned by `accept` instead of on the
listening socket.

Tentacle unfortunately does not seem to allow setting options on
accepted sockets, so TCP keepalive setting is removed for now.
@gw-bot
Copy link

gw-bot bot commented May 30, 2022

Running integration test

Workflow Run Id: 2407767058

Components:

Manually running integration test

Post a comment contains

/itest
[prebuilds: tag]
[godwoken: branch/ref]
[scripts: branch/ref]
[polyjuice: branch/ref]
[web3: branch/ref]
[kicker: branch/ref]
[tests: branch/ref]

Note: [] means optional, for example

/itest
prebuilds: dev-202203280240
godwoken: develop
scripts: 81676d9d53ffdf5bbaa60483928d07da16eb4a88
polyjuice: e37553b9

Run Result

success

// Start a hyper server.
let server = Server::builder(AddrIncoming::from_listener(listener)?)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/hyperium/hyper/blob/f8e2a831943e9a687a1b3277c806caca6e0ac8a4/src/server/tcp.rs#L48-L58

    /// Creates a new `AddrIncoming` from an existing `tokio::net::TcpListener`.
    pub fn from_listener(listener: TcpListener) -> crate::Result<Self> {
        let addr = listener.local_addr().map_err(crate::Error::new_listen)?;
        Ok(AddrIncoming {
            listener,
            addr,
            sleep_on_errors: true,
            tcp_keepalive_timeout: None,
            tcp_nodelay: false,
            timeout: None,
        })
    }

curious why hyper doesn't inherit the keepalive options from socket

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

Successfully merging this pull request may close these issues.

4 participants