Proxy 如何将Google Cloud PubSub与代理一起使用?
我正在使用一个与Google Cloud PubSub交互的应用程序。它在正常情况下工作正常,但我想启用代理支持,所以我正在浏览和Proxy 如何将Google Cloud PubSub与代理一起使用?,proxy,google-cloud-platform,google-cloud-pubsub,Proxy,Google Cloud Platform,Google Cloud Pubsub,我正在使用一个与Google Cloud PubSub交互的应用程序。它在正常情况下工作正常,但我想启用代理支持,所以我正在浏览和Subscriber类及其API,以查看是否有任何API可用于启用代理支持。我只找到了setChannelProvider,但我不确定这是否有效 下面的代码片段是我想使用的,但似乎不起作用 ManagedChannel channel = ManagedChannelBuilder.forAddress(proxyHost, proxyPort).build(); T
Subscriber
类及其API,以查看是否有任何API可用于启用代理支持。我只找到了setChannelProvider
,但我不确定这是否有效
下面的代码片段是我想使用的,但似乎不起作用
ManagedChannel channel = ManagedChannelBuilder.forAddress(proxyHost, proxyPort).build();
TransportChannelProvider channelProvider = FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel));
publisherBuilder.setChannelProvider(channelProvider);
我无法成功地发布
或将
消息拉入云服务。我得到以下错误:
java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded after 9978300322ns
因此,我想知道PubSub服务是否通过API支持代理,还是只支持代理设置,即仅在环境路径中提供主机和端口。Google Pub/Sub不支持通过HTTP进行代理身份验证,但可以使用配置
我找到了(这就是为什么我假设您使用的是HTTP),并使用我所说的进行了修复。Google Pub/Sub不支持通过HTTP进行代理身份验证,但可以使用进行配置
我找到了(这就是为什么我假设您使用的是HTTP),并通过使用我所说的进行了修复。您可以直接使用JVM args
https.proxyHost
,https.proxyPort
mvn clean install -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 exec:java
然后直接创建您选择的客户机
Topicadminings Topicadminings=Topicadminings.newBuilder().build();
TopicAdminClient TopicAdminClient=TopicAdminClient.create(topicAdminSettings);
仅供参考-此处设置managedChannel Builder.forAddress()
将覆盖pubsub的最终目标(应该是pubsub.googleapis.com
443
(不是代理)
这里是一个我放在一起的,以及一个专门针对pubsub和pubsub+的代理,它需要基本的auth头
最后,请注意,它的
https.proxyHost
即使您使用的是httpProxy,ref也可以直接使用JVM参数https.proxyHost
,https.proxyPort
mvn clean install -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 exec:java
然后直接创建您选择的客户机
Topicadminings Topicadminings=Topicadminings.newBuilder().build();
TopicAdminClient TopicAdminClient=TopicAdminClient.create(topicAdminSettings);
仅供参考-此处设置managedChannel Builder.forAddress()
将覆盖pubsub的最终目标(应该是pubsub.googleapis.com
443
(不是代理)
这里是一个我放在一起的,以及一个专门针对pubsub和pubsub+的代理,它需要基本的auth头
最后,请注意,它的
https.proxyHost
即使您使用的是httpProxy,ref您也需要设置JVM参数:https.proxyHost,https.proxyPort
对于代理身份验证,在创建任何客户端之前需要额外配置:
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return
new PasswordAuthentication(proxyUsername,proxyPassword).toCharArray());
}
您需要设置JVM参数:https.proxyHost、https.proxyPort 对于代理身份验证,在创建任何客户端之前需要额外配置:
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return
new PasswordAuthentication(proxyUsername,proxyPassword).toCharArray());
}