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

Reuse_addr / Clean shutdown #53

Closed
FredrikNoren opened this issue Aug 5, 2022 · 1 comment · Fixed by #54
Closed

Reuse_addr / Clean shutdown #53

FredrikNoren opened this issue Aug 5, 2022 · 1 comment · Fixed by #54

Comments

@FredrikNoren
Copy link

Hi,

I'm building a server which auto updates, but when it restarts I get "address in use" exceptions. As far as I can tell from hyperium/hyper#1575 I need to set reuse_addr, but I can't seem to find a way to do it through axum_server. Any chance it could be added? (I'm also using rustls).

@programatik29 programatik29 linked a pull request Aug 5, 2022 that will close this issue
@FredrikNoren
Copy link
Author

FredrikNoren commented Aug 5, 2022

For anyone else running into this; here's how it can be done in 0.4.2 (using socket2):

let addr = SocketAddr::from(([127, 0, 0, 1], 8080));
let socket = Socket::new(Domain::IPV4, Type::STREAM, None)?;
socket.set_reuse_address(true)?;
socket.bind(&addr.into())?;
socket.listen(128)?;
let listener: TcpListener = socket.into();
axum_server::from_tcp(listener)

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 a pull request may close this issue.

1 participant