failure to bind listening socket not handled
Opened this issue · 2 comments
Describe the bug
A message is logged when pingora-proxy fails to bind its listener port, but there doesn't appear to be any way to handle the failure.
The server remains up and running, but doesn't accept requests or recover if the desired port is freed.
The error that is logged to the console, for reference:
Failed to build listeners: Error { etype: BindError, esource: Unset, retry: Decided(false), cause: Some(Os { code: 48, kind: AddrInUse, message: "Address already in use" }), context: Some(Owned("bind() failed, after retries, 127.0.0.1:8000 still in use")) }
Pingora info
Please include the following information about your environment:
Pingora version: 0.5.0
Rust version: 1.88.0
Operating system version: macOS 15.5
Steps to reproduce
Can be reproduced using the code here: https://github.com/tmeumann/fakie
Assuming port 8000 is already bound, running the code in the linked repo will with the following parameters will reproduce the issue:
cargo run --listen 127.0.0.1:8000 https://example.com
Expected results
The process to exit, or the Pingora API to provide some other way to handle the failure.
Observed results
The server hangs, unable to accept requests.
Additional context
It's possible I'm missing something here. If so, please let me know!
I'm potentially open to working on a solution if desired.
the Pingora API to provide some other way to handle the failure
What approach would be preferable to you in terms of handling the failure?
Thanks for the reply!
There are two options that I see being preferable for the users of my project -- either (1) the process exits with an error message or (2) a different port is selected and bound (logged visibly so the user is aware). Option 1 would make the most sense for my project I think.
In terms of implementation in Pingora -- I'm not really sure what the best approach would be (callback, error bubbling, new trait function that can be impl'd or ??). I'd need some guidance on it if I was going to attempt to implement anything, because it looks like there would be a bit of refactoring involved.