racorn commented on issue #8056:
URL: https://github.com/apache/pulsar/issues/8056#issuecomment-692344168
@rdhabalia
Sorry for the confusion, I will try to clear things up.
The code below is `ConnectionPool.createConnection`:
```
/**
* Resolve DNS asynchronously and attempt to connect to any IP address
returned by DNS server
*/
private CompletableFuture<Channel> createConnection(InetSocketAddress
unresolvedAddress) {
String hostname = unresolvedAddress.getHostString();
int port = unresolvedAddress.getPort();
try {
// For non-sni-proxy: Resolve DNS --> Attempt to connect to all
IP addresses until once succeeds
CompletableFuture<List<InetAddress>> resolvedAddress =
isSniProxy()
?
CompletableFuture.completedFuture(Lists.newArrayList(InetAddress.getByName(hostname)))
: resolveName(hostname);
return resolvedAddress
.thenCompose(inetAddresses ->
connectToResolvedAddresses(inetAddresses.iterator(), port));
} catch (UnknownHostException e) {
log.error("Invalid remote url {}", hostname, e);
return FutureUtil.failedFuture(new InvalidServiceURL("Invalid
url " + hostname, e));
}
}
```
The `unresolvedAddress` argument is the broker host (broker service url). As
you can see, if SNI routing is used, the `unresolvedAddress `(broker host) is
resolved with `InetAddress.getByName`. If the broker host is not resolvable,
the method fails with an `UnknownHostException`. On the other hand, **if** the
broker is resolvable, `connectToResolvedAddresses` is invoked, which in turn
invokes `connectToAddress` where the broker address is set as the SNI host and
the proxy URL host is connected to instead. I mentioned this because I think it
shows that the code would work without the need to resolve the broker host when
using SNI routing.
My suggestions is to replace the `InetAddress.getByName(hostname)`
invocation above with `unresolvedAddress.getAddress` you want to enforce that
each broker host is resolvable to the client.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]