Configure Pub/Sub Java's gRPC Channel for HTTP CONNECT
Install a ProxyDetector through the GAX channel provider, keeping Pub/Sub's target address and TLS identity intact.
Use the generated client's channel provider when a Pub/Sub Java gRPC connection needs an HTTP CONNECT proxy. An ordinary URLConnection setting does not establish this channel configuration.
For the topic-admin client:
var channelProvider = TopicAdminSettings
.defaultGrpcTransportProviderBuilder()
.setChannelConfigurator(channel -> channel.proxyDetector(target ->
HttpConnectProxiedSocketAddress.newBuilder()
.setProxyAddress(new InetSocketAddress("proxy.example", 8080))
.setTargetAddress((InetSocketAddress) target)
.setUsername(proxyUser)
.setPassword(proxyPassword)
.build()))
.build();
var settings = TopicAdminSettings.newBuilder()
.setTransportChannelProvider(channelProvider)
.build();
try (TopicAdminClient client = TopicAdminClient.create(settings)) {
// Perform the application's intended topic-admin operation here.
}TopicAdminClient and TopicAdminSettings are Pub/Sub v1 classes; HttpConnectProxiedSocketAddress comes from io.grpc and InetSocketAddress from java.net. The example assumes the normal internet-address target used by this channel.
The detector returns a proxy connection address alongside the original target. The gRPC builder requires the proxy address to be resolved. Leave the service endpoint as Pub/Sub: replacing it with the proxy hostname would lose the service target and intended TLS identity.
Remove the username/password calls for an unauthenticated proxy; public HTTP candidates can be found in the HTTP proxy list. Those calls are the HTTP CONNECT credential interface, not SOCKS or a general NTLM implementation.
If the failure happens before the gRPC operation while an independently created credential obtains a token, inspect that credential's HTTP route. It is outside the channel provider shown here.