grpc-java icon indicating copy to clipboard operation
grpc-java copied to clipboard

can put the service instances on different ports?

Open zhongql opened this issue 10 years ago • 4 comments

i want to create gRPC server in python with client in java , and start up multiple service instances on different ports, can it work ? and the client how to support different ports ?

zhongql avatar Jan 23 '16 20:01 zhongql

Generally we would expect you to run multiple services on the same port, as long as they are in the same process. But yes, there is an issue with python: grpc/grpc#4418.

For dealing with multiple ports in Java, instead of doing:

ManagedChannelBuilder.forTarget("somehost")

Just do:

ManagedChannelBuilder.forTarget("somehost:1234")

Where 1234 is the appropriate port number you want to connect to.

ejona86 avatar Jan 23 '16 21:01 ejona86

Oh, so great , but the ManagedChannelBuilder.forTarget is a ExperimentalApi, temporarily can't use ?

zhongql avatar Jan 24 '16 03:01 zhongql

Oh, you're right, it is still experimental. Honestly, that particular API is unlike to change much. But there is also ManagedChannelBuilder.forAddress(String name, int port) which is stable.

ejona86 avatar Jan 24 '16 20:01 ejona86

ok, thank you very much

zhongql avatar Jan 25 '16 05:01 zhongql