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

Graceful shutdown doesn't include upgraded connections #40

Closed
jeremycline opened this issue Mar 12, 2022 · 2 comments
Closed

Graceful shutdown doesn't include upgraded connections #40

jeremycline opened this issue Mar 12, 2022 · 2 comments

Comments

@jeremycline
Copy link

Hi,

When using Axum with WebSockets, I noticed having an open WebSocket doesn't stop the server from shutting down gracefully. Here's a demo repository.

My expectation was that the demo would remain running for 30 seconds, printing "beep" every second until the graceful shutdown timeout is reached.

I'm not terribly familiar with Hyper so I don't immediately see a fix, so I figured I'd start with an issue. I'm happy to work on a fix, however.

@programatik29
Copy link
Owner

The reason is hypers http future is terminated after upgrade response.

Take a look at serve_connection. This future terminates even if there is an upgraded connection.

@jeremycline
Copy link
Author

FWIW the way I solved this (and I'm embarrassed it took me a while to think of) is to just stash a channel handle in my shared state structure and each WebSocket takes a clone, just like the graceful shutdown tutorial for tokio. After the server shuts down the state gets dropped so it'll hang out until the WebSockets are done.

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