Skip to content

Get local websocket port upon launching rr.serve with ws_port=0 #7237

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

Open
carueda opened this issue Aug 19, 2024 · 4 comments
Open

Get local websocket port upon launching rr.serve with ws_port=0 #7237

carueda opened this issue Aug 19, 2024 · 4 comments
Labels
enhancement New feature or request 🪵 Log & send APIs Affects the user-facing API for all languages

Comments

@carueda
Copy link

carueda commented Aug 19, 2024

Is your feature request related to a problem? Please describe.

I have a "server" app (in python) that dynamically launches (and kills) rerun websocket server instances. Client apps (with Rerun viewer in them) will then connect to any of those instances. So far so good. However, having to manually (pre)determine the ports those instances will run on is a bit of a hassle.

Describe the solution you'd like

A convenient/reasonable solution is that, upon launching with rr.serve(ws_port=0, ...), there's a Rerun API that reports the local port that was assigned. (apologies if such thing already exists and I'm just not finding it.)

I'm using rerun-sdk 0.16.1 [EDIT:] 0.17.0

Describe alternatives you've considered

Such port shows up as part of INFO logging, eg:

[2024-08-19T23:21:53Z INFO  re_ws_comms::server] Hosting a WebSocket server on ws://localhost:34707. You can connect to this with ...

but not ideal having to parse it from there.

@carueda carueda added enhancement New feature or request 👀 needs triage This issue needs to be triaged by the Rerun team labels Aug 19, 2024
@Wumpf Wumpf added 🪵 Log & send APIs Affects the user-facing API for all languages and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Aug 20, 2024
@carueda
Copy link
Author

carueda commented Mar 6, 2025

Hi @Wumpf - any updates on this?

I'm in the process of upgrading an application from using Rerun 0.16.1 to the latest (at this point, 0.22.1). This is advancing well, but I note that my workaround above to get the port upon launching rr.serve_web(ws_port=0, ...) is not effective anymore. Thanks.

@carueda
Copy link
Author

carueda commented Mar 6, 2025

Ah, seems like the default logging level is now less than INFO, so it should be an easy fix on my side to keep the workaround functional: just define the env var RUST_LOG=info for when my python program launches serve_web:

$ RUST_LOG=info poetry run python rrws/main.py
[2025-03-06T23:06:24Z INFO  re_ws_comms::server] Hosting a WebSocket server on ws://localhost:42459. You can connect to this with a native viewer (`rerun ws://localhost:42459`) or the web viewer (with `?url=ws://localhost:42459`).
[2025-03-06T23:06:25Z INFO  re_sdk::web_viewer] Hosting a web-viewer at http://localhost:36621?url=ws://localhost:42459

@carueda
Copy link
Author

carueda commented Mar 25, 2025

I've removed the workaround and now pre-determine the socket port before calling serve_web. Closing this out to help tidy up the tracker.

@carueda carueda closed this as completed Mar 25, 2025
@Wumpf
Copy link
Member

Wumpf commented Mar 31, 2025

Thanks! But that's still an annoying issue though, there should be some more standardized way to retrieve the port when using automatic port selection

@Wumpf Wumpf reopened this Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🪵 Log & send APIs Affects the user-facing API for all languages
Projects
None yet
Development

No branches or pull requests

2 participants