kk1957
kk1957

Reputation: 8824

Zookeeper java username password

My Zookeeper instance is running on a server host:port

If I want to access it via web browser I first have to login via username/password and then only able to access my Zookeeper instance.

However in java, when I try this:

    String hostPort = "host:port";
    System.out.println("Trying to connect");
    ZooKeeper zk = new ZooKeeper(hostPort, 3000, this);
    String data = "some byte data";
    try {
        zk.create("/a/b", data.getBytes(), null, CreateMode.PERSISTENT);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

I get the following output:

Trying to connect
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
KeeperErrorCode = ConnectionLoss for /a/b

I am sure that it is because I am not able to provide username/password for server authentication. How can I achieve what I want to in java?

Upvotes: 0

Views: 3020

Answers (1)

kk1957
kk1957

Reputation: 8824

There was no server authentication required. In fact I was connecting via incorrect interface which needed authentication.

Upvotes: 1

Related Questions