Hyper 1.0.0-rc.3 - how to gracefully shutdown server connection after time delay? #3239
-
|
In a server using hyper 1.0.0-rc3, I want to shutdown incoming connections from clients after a time delay (say 2 minutes). Based on this example which uses Some questions:
Below is a small snippet of my code. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
After more testing - have come up with below code:
In tests have observed:
I think this works well for my needs. Thanks for any inputs - hope this is a reasonable solution! 😄 Updated code in my application: https://github.com/aaronriekenberg/rust-hyper-server/blob/main/src/server/connection.rs#L103-L122 |
Beta Was this translation helpful? Give feedback.
After more testing - have come up with below code:
CONNECTION_MAX_LIFETIME_DURATION= 2 mins to time out connectionCONNECTION_MAX_LIFETIME_DURATIONcallconn.graceful_shutdown()tokio::select!in case of in-progress request whenCONNECTION_MAX_LIFETIME_DURATIONelapsedCONNECTION_GRACEFUL_SHUTDOWN_DURATION= 5 seconds on second loop to give time for graceful shutdownIn tests have observed: