Connection handshake failed: org.apache.pulsar.client.api.PulsarClientException: Connection already closed
I had apache pulsar cluster in azure . Now i would like to connect to remote cluster from my local mahcine using Proxy
In **proxy.conf** file i set up configuration like this
--- Broker Discovery ---
zookeeperServers=xx.xx.xx.xx:2181,xx.xx.xx.xx:0:2181,xx.xx.xx.xx::2181
configurationStoreServers=xx.xx.xx.xx::2181,xx.xx.xx.xx::2181,xx.xx.xx.xx:xx:2181
brokerServiceURL=pulsar://xx.xx.xx.xx::6650,xx.xx.xx.xx::6650,xx.xx.xx.xx::6650 brokerServiceURLTLS= brokerWebServiceURL=http://xx.xx.xx.xx::8080,xx.xx.xx.xx::8080,xx.xx.xx.xx::8080
---------------------------------------------------------------------------------------------
In client.conf file i set up configuration like this
webServiceUrl=http://xx.xx.xx.xx:8080,xx.xx.xx.xx:8080,xx.xx.xx.xx:8080
brokerServiceUrl=pulsar://xx.xx.xx.xx:8080,xx.xx.xx.xx:8080,xx.xx.xx.xx:8080
---------------------------------------------------------------------------------------------
After that i ran this command u can see the below logs even proxy ran well
**bin/pulsar proxy **
13:55:44.775 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6bd16207{/lookup,null,AVAILABLE} 13:55:44.788 [main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@3a0807b7{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} 13:55:44.788 [main] INFO org.eclipse.jetty.server.Server - Started @16022ms 13:55:44.789 [main] INFO org.apache.pulsar.proxy.server.WebServer - Server started at end point http://0.0.0.0:8080
In another terminal
bin/pulsar-client consume my-topic -s "first-subscription"
Then i faced below error
Connection handshake failed: org.apache.pulsar.client.api.PulsarClientException: Connection already closed 13:59:44.816 [pulsar-external-listener-3-1] WARN org.apache.pulsar.client.impl.PulsarClientImpl - [topic: persistent://public/default/my-topic] Could not get connection while getPartitionedTopicMetadata -- Will try again in 2960 ms 13:59:45.079 [pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.Connect
Could you please help check if the problem only happens when the topic does not exist?
@balakrishna222111 Any update for this issue?
This also happens when the topic exists, it is sporadic
After this happens, the connection is re-established and the message can still be sent successfully.

I am sending the message asynchronously, the exception is thrown here.
The issue had no activity for 30 days, mark with Stale label.
Hey Team,
similar error we are getting when we are trying the load test with 1000 threads creating producers for sending simple string message & similarly for consuming.
Any suggestions would be really helpful.
Increasing the connectiontimeout & operationtimeout 5-10 minutes made the connection to reestablish and was able to resolve the frequent connection already closed issue