cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI to detect used ports

Open artursouza opened this issue 2 years ago • 3 comments

Describe the proposal

When using dapr run, the CLI should proactively detect the currently used ports and error out with a clear message. This should be true for every port the CLI will use: Dapr HTTP port, Dapr gRPC port, App port and metrics. This can reduce a lot of friction when getting started on Dapr or simply day to day troubleshooting. The App port should be checked ONLY if there is a command to be executed after dapr run -- since the app can be executed separately from the dapr run invocation.

Release Note

RELEASE NOTE: ADDED validation for currently used ports prior to executing dapr run

artursouza avatar Jul 12 '22 02:07 artursouza

If dapr run -- is executed, we can check that the app-port is already in use (desired). If there is a command provided, then we can ensure that the app-port is not already in use!

berndverst avatar Jul 12 '22 18:07 berndverst

The option that I see here is to do something similar to what the FreePort method does, make a connection to an incoming port and see if it is free or not and then close connection if it is free ... That though would increase the delay for run IMO ... WDYT?

mukundansundar avatar Aug 11 '22 06:08 mukundansundar

This is partially already available ie checking if a port is already being used for HTTP, gRPC and metrics port ...

# Run 
dapr run -H 3500 

in two different shells, you will get the error

WARNING: no application command found.
❌  invalid configuration for HTTPPort. Port 3500 is not available

The only enhancement needed here is when dapr run has an app command to run, then the app port must not be an existing app port and that should error out similar to what we see above.

mukundansundar avatar Aug 11 '22 08:08 mukundansundar

@artursouza These checks are present already as far as I can see.

mukundansundar avatar Jan 27 '23 07:01 mukundansundar

@artursouza These checks are present already as far as I can see.

Can we close this issue if that is the case please?

sicoyle avatar Sep 21 '23 22:09 sicoyle