0

我正在尝试配置谷歌语音 api 以在公司防火墙内的项目中工作。我已将 SpeechSettings 配置如下:

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);

使用它可以在代理网络之外正确工作并启动语音识别会话。但它无法在代理身份验证网络下转录任何内容,并且UNAVAILABLE: Transport closed for unknown reason在 ApiStreamObserver 类中出现此错误并超时。我认为 Grpc 传输由于防火墙超时而被关闭。

在创建语音客户端会话时是否可以使用代理身份验证凭据进行身份验证?谢谢。

4

2 回答 2

0

你能澄清一下你使用的是什么代理网络吗?您使用的是 Google Cloud Endpoints ( https://cloud.google.com/endpoints ) 吗?您的项目是否在 Google Cloud Platform 上运行?如果有,具体是什么平台?应用引擎灵活?应用引擎标准?计算引擎?容器引擎?

于 2017-09-18T18:37:06.770 回答
0

环境变量GRPC_PROXY_EXP已被弃用,虽然它目前仍然有效,但您应该能够使用标准的 java 属性https.proxyHosthttps.proxyPort. 直接在当前 JVM 中以编程方式设置它们(不推荐):

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

或者在启动 JVM 时,例如

java   .... -Dhtts.proxyHost=myproxy.host.local -Dhttps.proxyPort=8080 ...
于 2020-02-04T14:23:41.237 回答