How can I setup proxy settings in c# for Google Cloud Txt-To-Speech API

Viewed 58

How to setup a proxy in c# code for Google Text-To-Speech API.

Does somebody knows where to put in the proxy settings for the Google TTS API in c#. Our project runs locally but not on the server behind a firewall, so it has to go via the proxy.

Hope you have a starting point for me ;-)

Thanks!

1 Answers

The intention is that if you've set the system proxy, or the HTTPS_PROXY environment variable, that should just work by default.

However, at the moment there's a bug in Grpc.Net.Client that causes that to fail. (Once it's been fixed and released, we'll obviously update our dependencies for the next release of Google.Cloud.TextToSpeech.V1 and other Cloud libraries.)

The simplest workaround is probably to still use the Grpc.Net.Client implementation of gRPC, but with an additional option:

var client = new TextToSpeechClientBuilder
{
    GrpcAdapter = GrpcNetClientAdapter.Default.WithAdditionalOptions(
        options => options.HttpHandler = new HttpClientHandler
        {
            Proxy = new WebProxy("your proxy here"),
            UseProxy = true
        })
}.Build();
Related