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

Using dynamic port numbers #37

Open
jmaslak opened this issue Jan 11, 2023 · 1 comment
Open

Using dynamic port numbers #37

jmaslak opened this issue Jan 11, 2023 · 1 comment

Comments

@jmaslak
Copy link

jmaslak commented Jan 11, 2023

It would be amazing if there was a way you could get the port number Cro listens at when you pass it a "0" for the port number. This would let Cro bind to a free port, which could be very useful in test harnesses, as hardcoding a port in the test harness is not guaranteed to be free from collisions. However, today there is no way that I know of to determine the port number it binds to if using a dynamic port, at least not in a portable way.

@jmaslak
Copy link
Author

jmaslak commented Jan 11, 2023

FWIW, I'm working around this by swapping out the listener in the service object with one that lets me get the port number. But using Cro this way feels...really wrong. :)

See example: https://gist.github.com/jmaslak/ba3cbfe1abd13b76ac906cfaeb0f62e9

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

1 participant