I also had the same requirement, and it turned out that the connection to the ZooKeeper client was implemented through NIO (org.apache.zookeeper.ClientCnxnSocketNIO). And NIO does not support socks
Make the getClientCnxnSocket () method on ZooKeeper.java if you have a source.
private static ClientCnxnSocket getClientCnxnSocket() throws IOException { String clientCnxnSocketName = System .getProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET); if (clientCnxnSocketName == null) { clientCnxnSocketName = ClientCnxnSocketNIO.class.getName(); } try { return (ClientCnxnSocket) Class.forName(clientCnxnSocketName) .newInstance(); } catch (Exception e) { IOException ioe = new IOException("Couldn't instantiate " + clientCnxnSocketName); ioe.initCause(e); throw ioe; } }
If you want it to work on socks, you need to provide your own implementation by extending ClientCnxnSocket and specifying it using System variable zookeeper.clientCnxnSocket).
source share