Multiple services registered to different ports / C++

33 views
Skip to first unread message

ant...@modbot.com

unread,
Mar 20, 2018, 11:08:34 PM3/20/18
to grpc.io
Hello, 

I'm looking to register multiple services to the same (sync) server in C++, ideally specifying a different IP / port for each.
The ServerBuilder documentation suggests that I'm able to specify a host along with the service I'm registering to the server, a la

builder.registerService(host_string, &service)

However, when I provide a host string in the format "[ip]:[port]" (or a more concrete ex; `0.0.0.0:50051`), no clients are able to successfully make RPCs to the server, calls which would otherwise work if I simply registered to the default host using registerService([service addr]). 
Providing an IP without port and vice versa don't work either. The documentation doesn't elaborate on the format the function expects for the function param std::string host. What should I be providing here?

Cheers, 
Antonia

Yang Gao

unread,
Apr 9, 2018, 7:27:50 PM4/9/18
to grpc.io
My understanding is that you register the service with a host string to match a client using the corresponding authority
for example

registerService("other_service.myapi.com", service)

and the client to use

client_context.set_authority("other_service.myapi.com");
and then makes the rpc.

At the server side, grpc library will first try to find an exact match of the :authority header on the wire with the registered services. If it cannot find any it will try to just look for the method name with the registered services.
Reply all
Reply to author
Forward
0 new messages