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

Question: Is it possible to start proxy on a random port - how does one retrieve the port? #1675

Open
Nick-Minutello opened this issue Jul 29, 2024 · 2 comments

Comments

@Nick-Minutello
Copy link

We want to run http-proxy in our automated tests (to simulate the behaviour of our sso reverse proxy). In some cases, we may want to start a number of proxies.

In automated tests, we like to start servers on random free ports, so as to avoid any port clashes.

Of course I could call proxy.listen(0) - but it isn't clear how I can get the resultant port.

Thanks in advance

@Nick-Minutello
Copy link
Author

It is possible, reaching into the internals ....

proxy._server.address().port

@timtucker-dte
Copy link

Why not pass in a list of potential ports into your testing scripts as input?

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

2 participants