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.

On Wed, Dec 13, 2023 at 10:10 AM D Dob <ober.ist.den...@gmail.com> wrote:

> 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,
>
> .
> On Tuesday 12 December 2023 at 22:28:03 UTC+1 Mark D. Roth wrote:
>
>> 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.
>>
>> For details, see
>> https://github.com/grpc/grpc/blob/master/doc/service_config.md.
>>
>> On Monday, December 11, 2023 at 2:08:52 PM UTC-8 D Dob wrote:
>>
>>> 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:
>>> client logs: https://pastebin.com/sFq8FyWa
>>> server logs: https://pastebin.com/HA54iAAw
>>> relevant code: https://pastebin.com/u6bigcAj
>>>
>>> Any help or pointer to an example/test would be greatly appreciated.
>>> Maybe i've just not understood something
>>>
>>> best,
>>>
>>> Dennis
>>>
>> --
> 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+unsubscr...@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
> <https://groups.google.com/d/msgid/grpc-io/b47716dd-4bec-4998-8d23-6857a794ca8an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Mark D. Roth <r...@google.com>
Software Engineer
Google, Inc.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAJgPXp7neviRC2QXBeTVSGGyDb5bEeE47vNW_XcL8oanp2ZOug%40mail.gmail.com.

Reply via email to