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

Auto-switch port when getting: "RuntimeError: Failed to bind to WebSocket port 9877: Address already in use (os error 98)" #4241

Closed
saryazdi opened this issue Nov 15, 2023 · 0 comments · Fixed by #4314
Labels
enhancement New feature or request good first issue Good for newcomers 🏎️ Quick Issue Can be fixed in a few hours or less
Milestone

Comments

@saryazdi
Copy link

saryazdi commented Nov 15, 2023

Describe the annoyance

Currently if there's a rerun server already using WebSocket port 9877 on a machine, rr.serve throws the following error:

RuntimeError: Failed to bind to WebSocket port 9877: Address already in use (os error 98)

To Reproduce

  1. Launch a script that runs rr.serve (I ran into it on python, but you can try cd rerun/examples/rust && cargo run --bin minimal_serve)
  2. While 1 is running, launch above script again in another terminal.

Expected behavior

Assign a different free port (e.g. streamlit does this also).

Your goals

  • Having multiple rr.serve sessions open
  • Running rr.serve on a shared machine/server where multiple users might simultaneously be using rerun

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.6 LTS
@saryazdi saryazdi added 👀 needs triage This issue needs to be triaged by the Rerun team 😤 annoying Something in the UI / SDK is annoying to use labels Nov 15, 2023
@emilk emilk added enhancement New feature or request and removed 😤 annoying Something in the UI / SDK is annoying to use 👀 needs triage This issue needs to be triaged by the Rerun team labels Nov 16, 2023
@emilk emilk added this to the Triage milestone Nov 16, 2023
@emilk emilk added 🏎️ Quick Issue Can be fixed in a few hours or less good first issue Good for newcomers labels Nov 16, 2023
teh-cmc pushed a commit that referenced this issue Nov 24, 2023
Closes #4241 
Allows for multiple rr.serve() sessions open by trying different ports
if the defaults are already in use. This is achieved by attempting to
bind to port 0, which signals the OS to choose a free port.

Some notes:
Since the hyper::Error type does not provide a method to directly check
if the error is due to a port being already in use, I checked the error
string to implement this.
I'm also ignoring the error thrown by format!("{bind_ip}:0").parse() as
it's not possible to convert it into a hyper::Error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers 🏎️ Quick Issue Can be fixed in a few hours or less
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants