Proxy Authentication for Google Speech Api Credential

1k views Asked by At

I am trying to configure google speech api to work in my project within the company's firewall. I have configured the SpeechSettings as following:

InputStream is = this.getClass().getResourceAsStream("/my-service-account.json");           
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(is));
SpeechSettings.Builder builder = SpeechSettings.newBuilder();
builder.setTransportProvider(SpeechSettings.defaultTransportProvider());
builder.setCredentialsProvider(credentialsProvider);
SpeechSettings settings =  builder.build();
SpeechClient.create(settings);

Using this works outside proxy network correctly and starts a speech recognize session. But it fails to transcribe anything under a proxy authenticated network and times out with this error- UNAVAILABLE: Transport closed for unknown reasonin ApiStreamObserver class.I am thinking the Grpc transport is being closed because of the firewall timeout.

Is it possible to authenticate with the proxy authentication credentials while creating the speech client session? Thanks.

1

There are 1 answers

0
siddhadev On

The environment variable GRPC_PROXY_EXP has been deprecated, and while it currently still works, you should be able to use the standard java properties https.proxyHost and https.proxyPort. Either setting them programmatically directly in the current JVM (not recommended):

System.setProperty("https.proxyHost", "myproxy.host.local");
System.setProperty("https.proxyPort", "8080");

or when starting the JVM, e.g.

java   .... -Dhtts.proxyHost=myproxy.host.local -Dhttps.proxyPort=8080 ...