You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option "grpc.so_reuseport" does not work correctly on Linux OS. #794
I agree that it would be good to implement this functionality in this library.
However, we do not recommend using that feature to accomplish what it looks like you are trying to accomplish. If you want to force your server instances to bind to different ports, you should either bind to port 0 or use some out-of-band mechanism to assign ports to your server instances. In both cases, you shouldn't be frequently running into this case where two servers are attempting to bind the same port.
We have several different grpc-microservices whish can be run on the same server within selected port range and which register themself to Service Discovery Server.
In case of enabled flag 'so_reuseport' two or more different services can be binded to the same port on the server.
For example: Service1 on 48000, Service2 on 48000.
In this case any grpc-client will have a chance to connect to wrong service.
For example: a grpc-client wants to use Service2 and finds port 48000 on the ServiceDiscovery and has a chance to connect to Service1 instead.
In the C++ code we set the option GRPC_ARG_ALLOW_REUSEPORT to 0 ant it works fine.
In Nodejs the same option {"grpc.so_reuseport": 0} works on Windows but does not work Linux.
It seems there is the different behaviour of the one code on different systems.
Activity
murgatroid99 commentedon Mar 19, 2019
I agree that it would be good to implement this functionality in this library.
However, we do not recommend using that feature to accomplish what it looks like you are trying to accomplish. If you want to force your server instances to bind to different ports, you should either bind to port 0 or use some out-of-band mechanism to assign ports to your server instances. In both cases, you shouldn't be frequently running into this case where two servers are attempting to bind the same port.
plitvinov commentedon Mar 20, 2019
Hi
We have several different grpc-microservices whish can be run on the same server within selected port range and which register themself to Service Discovery Server.
In case of enabled flag 'so_reuseport' two or more different services can be binded to the same port on the server.
For example: Service1 on 48000, Service2 on 48000.
In this case any grpc-client will have a chance to connect to wrong service.
For example: a grpc-client wants to use Service2 and finds port 48000 on the ServiceDiscovery and has a chance to connect to Service1 instead.
In the C++ code we set the option GRPC_ARG_ALLOW_REUSEPORT to 0 ant it works fine.
In Nodejs the same option {"grpc.so_reuseport": 0} works on Windows but does not work Linux.
It seems there is the different behaviour of the one code on different systems.
nicolasnoble commentedon Mar 20, 2019
Why can't you bind on port 0?
plitvinov commentedon Mar 20, 2019
We need to bind to port range due network firewall rules.
We have only a group of ports opened by firewall rules.
zyf0330 commentedon Nov 11, 2020
Hello, is there any progress?
murgatroid99 commentedon May 11, 2021
The
grpcpackage has been deprecated, so we will not be making further changes to this functionality. We recommend using@grpc/grpc-jsinstead.