Prevent port collisions
During the workshop you will run the services in the solution on your local machine. To prevent port-collisions, all services listen on a different HTTP port. When running the services with Dapr, you need additional ports for HTTP and gRPC communication with the sidecars. By default these ports are 3500
and 50001
. But to prevent confusion, you’ll use totally different port numbers in the assignments. If you follow the instructions, the services will use the following ports for their Dapr sidecars to prevent port collisions:
Service | Application Port | Dapr sidecar HTTP port | Dapr sidecar gRPC port |
---|---|---|---|
TrafficControlService | 6000 | 3600 | 60000 |
FineCollectionService | 6001 | 3601 | 60001 |
VehicleRegistrationService | 6002 | 3602 | 60002 |
If you’re doing the DIY approach, make sure you use the ports specified in the table above.
The ports can be specified on the command-line when starting a service with the Dapr CLI. The following command-line flags can be used:
--app-port
--dapr-http-port
--dapr-grpc-port
If you’re on Windows with Hyper-V enabled, you might run into an issue that you’re not able to use one (or more) of these ports. This could have something to do with aggressive port reservations by Hyper-V. You can check whether or not this is the case by executing this command:
netsh int ipv4 show excludedportrange protocol=tcp
If you see one (or more) of the ports shown as reserved in the output, fix it by executing the following commands in an administrative terminal:
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
netsh int ipv4 add excludedportrange protocol=tcp startport=6000 numberofports=3
netsh int ipv4 add excludedportrange protocol=tcp startport=3600 numberofports=3
netsh int ipv4 add excludedportrange protocol=tcp startport=60000 numberofports=3
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All