eolivelli commented on code in PR #17082:
URL: https://github.com/apache/pulsar/pull/17082#discussion_r956763118


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java:
##########
@@ -493,13 +502,47 @@ private URI getRedirectionUrl(ClusterData 
differentClusterData) throws Malformed
             } else {
                 
serviceNameResolver.updateServiceUrl(differentClusterData.getServiceUrl());
             }
-            URL webUrl = new 
URL(serviceNameResolver.resolveHostUri().toString());
-            return 
UriBuilder.fromUri(uri.getRequestUri()).host(webUrl.getHost()).port(webUrl.getPort()).build();
+            return getConnectableURI(serviceNameResolver);
         } catch (PulsarClientException.InvalidServiceURL exception) {
             throw new MalformedURLException(exception.getMessage());
         }
     }
 
+    private CompletableFuture<URI> getConnectableURI(PulsarServiceNameResolver 
serviceNameResolver) {
+        return CompletableFuture.supplyAsync(() -> {
+            String hostUri = serviceNameResolver.resolveHostUri().toString();
+            String firstHostUri = hostUri;
+            boolean connectable = false;
+            URL webUrl = null;
+            do {
+                try {
+                    webUrl = new URL(hostUri);
+                    Socket socket = new Socket();
+                    socket.connect(new InetSocketAddress(webUrl.getHost(), 
webUrl.getPort()), 5000);

Review Comment:
   This is going to create dunmy TCP connections to Pulsar brokers.
   I don't think that the broker will be happy.
   
   
   If you need thus feature that we must add a configuration flag to enable 
this new behaviour 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to