Search code examples
solrapache-zookeepersolrjsolrcloud

Not able to connect to SOLR through CloudSolrClient?


I am facing some issue while connecting to Solr through CloudSolrClient.
I used the following piece of code.

CloudSolrClient server = new CloudSolrClient("ip:8983");
server.setDefaultCollection("hadoop_logs_shard3_replica1");

I am getting following error


    java.io.IOException: Packet len1213486160 is out of range!
        at org.apache.zookeeper.ClientCnxnSocket.readLength(ClientCnxnSocket.java:112)
        at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:79)
        at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)


Solution

  • public CloudSolrClient(String zkHost)
    

    Create a new client object that connects to Zookeeper and is always aware of the SolrCloud state. Updates will be sent to shard leaders by default.

    You are specifying solr instance host:port instead of zookeeper host:port. Fix that, It should work afterwards.