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

瀏覽次數:64 次
跳到第一則未讀訊息

D Dob

未讀,
2023年12月11日 下午5:08:522023/12/11
收件者: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

未讀,
2023年12月12日 下午4:28:032023/12/12
收件者: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

未讀,
2023年12月13日 下午1:10:182023/12/13
收件者: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

未讀,
2023年12月13日 下午3:51:172023/12/13
收件者: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.
回覆所有人
回覆作者
轉寄
0 則新訊息