Skip to content

Conversation

@anitarua
Copy link
Contributor

@anitarua anitarua commented Sep 26, 2025

Was locally testing v0.10.0 + setting SO_REUSEADDR but it wasn't working.
Used this stackoverflow workaround to set both keepalive and other socket settings instead.


socket.set_nonblocking(true)?;
socket.set_tcp_nodelay(true)?;
socket.set_tcp_keepalive(&tcp_keepalive)?;
Copy link
Owner

Choose a reason for hiding this comment

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

Okay, I think this is what this code should do:

    let stream = TcpStream::connect(&address).await?;
    // For setting socket configuration options available to socket2
    let socket = socket2::SockRef::from(&stream);

    let mut tcp_keepalive = TcpKeepalive::new();
    if let Some(duration) = configuration.tcp_keepalive_duration {
        tcp_keepalive = tcp_keepalive.with_time(duration);
    }

    socket.set_nonblocking(true)?;
    socket.set_tcp_nodelay(true)?;
    socket.set_tcp_keepalive(&tcp_keepalive)?;
    socket.set_reuse_address(true)?;

    let message_reactor: RpcCompletionReactor<

@anitarua anitarua changed the title fix: socket was not connecting + enable reuse port/address fix: socket was not connecting + enable reuse address Sep 27, 2025
Copy link
Owner

@kvc0 kvc0 left a comment

Choose a reason for hiding this comment

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

looks great, thank you!

@kvc0 kvc0 merged commit 34762d3 into kvc0:main Sep 27, 2025
1 check passed
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.

2 participants