gRPC, C++ - Server side 'service_config' not recognized by clients

64 views
Skip to first unread message

D Dob

unread,
Dec 11, 2023, 5:08:52 PM12/11/23
to grpc.io
Hey all,

I'm having a hard time to set the service_config on my server side and have it received by a client. I'm testing it in a small playground project and am currently out of ideas in how to get this working. Rough project setup and findings:

OS: linux, gRPC: v.160, v.1.58

Server:
~~~
const auto serviceConfig = readFile("service_config.json");
builder.AddChannelArgument(GRPC_ARG_SERVICE_CONFIG, *serviceConfig);

Client:
~~~
const auto channel = grpc::CreateChannel(Address.data(), grpc::InsecureChannelCredentials());
std::cout << std::format("Server config: \n{}\n", channel->GetServiceConfigJSON());
Client client(channel);
client.sstream(10);

Client c-ares logs:
[polling resolver 0x55eb2c40a410] request complete                                                  
[polling resolver 0x55eb2c40a410] returning result: addresses=<2 addresses>, service_config=<null>  
chand=0x55eb2c406d80: got resolver result                                                            
chand=0x55eb2c406d80: resolver returned no service config. Using default service config for channel.
chand=0x55eb2c406d80: using service config: "{}"

As to my understanding setting it via GRPC_ARG_SERVICE_CONFIG should be all it
takes. Logs from c-ares look fine in general but it still can't find the service_config. I've been
playing around with various settings but no luck :(

Didn't want to pollute the chat here:
server logs: https://pastebin.com/HA54iAAw            

Any help or pointer to an example/test would be greatly appreciated. Maybe i've just not understood something

best,

Dennis                                       

Mark D. Roth

unread,
Dec 12, 2023, 4:28:03 PM12/12/23
to grpc.io
The service config is not sent by the gRPC server.  It cannot be done that way, because the service config sets parameters that are needed on the client before the client has contacted any server.  Instead, the service config is intended to be returned to the client via the name resolver.  There is also a local API that you can use to have the client application set the default service config directly.

D Dob

unread,
Dec 13, 2023, 1:10:18 PM12/13/23
to grpc.io
Thanks! I was under the impression that GRPC_ARG_SERVICE_CONFIG is already including it to the name resolver. I was aware of the client side configuration but it seems like its primary purpose is for debugging/testing. How can I set it then on the server side. Does gRPC provide API to interact with the name resolver? It's pretty hard to get information about this topic, given my very limited knowledge about this topic.

best,

.

Mark D. Roth

unread,
Dec 13, 2023, 3:51:17 PM12/13/23
to D Dob, grpc.io
There is no way to set the service config on the gRPC server side.

The name resolver has nothing to do with the gRPC server side; the name resolver is the component in the client that resolves a name into a set of addresses, so that the client knows what servers to connect to.  For more information, see https://github.com/grpc/grpc/blob/master/doc/naming.md.  The DNS resolver provides a way to get the service config from a TXT record, as described in https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md.

Alternatively, you can set GRPC_ARG_SERVICE_CONFIG directly on the client side.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b47716dd-4bec-4998-8d23-6857a794ca8an%40googlegroups.com.


--
Mark D. Roth <ro...@google.com>
Software Engineer
Google, Inc.
Reply all
Reply to author
Forward
0 new messages