Hi there,
I post this question here since the mailing list has been just set up.
I was wondering if someone is aware of any issue trying to use Curator against a Zookeeper Server that is set to use SASL (ConnectionLossException) since I cannot make it work Curator to make operations or watching events.
I've actually posted a similar message onto the Zookeeper mailing list. Thanks Jordan for the answer but I think I've mislead you.
After some tests I can add more details:
I have a zookeeper server with:
"-Djava.security.auth.login.config=C:\apps\zookeeper-3.4.3\jaas.conf"
and authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
and using the zkClient.sh to add a node everything works fine.
When I try to do any operation using a Curator client I get a:
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss
after the node is added.
I'm using zookeeper 3.4.3 and Curator 1.1.5 (but I've tried with ZK 3.4.2 as well)
Example:
Using a Curator client I do:
System.setProperty("java.security.auth.login.config", "C:\apps\zookeeper-3.4.3\client_jaas.conf");
CuratorFramework client = CuratorFrameworkFactory.newClient("127.0.0.1:2183", new RetryNTimes(10, 1000));
client.start();
[...]
client.create().withMode(nodeMode).withACL(ZooDefs.Ids.READ_ACL_UNSAFE).forPath(fullPath, data);
this returns in the client shell:
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss
at com.netflix.curator.ConnectionState.getZooKeeper(ConnectionState.java:84)
at com.netflix.curator.CuratorZookeeperClient.getZooKeeper(CuratorZookeeperClient.java:90)
at com.netflix.curator.framework.imps.CuratorFrameworkImpl.getZooKeeper(CuratorFrameworkImpl.java:381)
at com.netflix.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:184)
at com.netflix.curator.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:173)
at com.netflix.curator.RetryLoop.callWithRetry(RetryLoop.java:85)
at com.netflix.curator.framework.imps.GetChildrenBuilderImpl.pathInForeground(GetChildrenBuilderImpl.java:169)
at com.netflix.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:161)
at com.netflix.curator.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:36)
at com.netflix.curator.framework.recipes.cache.PathChildrenCache.rebuild(PathChildrenCache.java:199)
at com.netflix.curator.framework.recipes.cache.PathChildrenCache.start(PathChildrenCache.java:179)
at com.workday.zookeeper.examples.MyChildrenWatcher.main(MyChildrenWatcher.java:53)
while onto the zk server log:
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:NIOServerCnxnFactory@213] - Accepted socket connection from /127.0.0.1:54393
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:ZooKeeperServer@838] - Client attempting to establish new session at /127.0.0.1:54393
[myid:] - INFO [SyncThread:0:ZooKeeperServer@604] - Established session 0x136b09915f00008 with negotiated timeout 15000 for client /127.0.0.1:54393
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:SaslServerCallbackHandler@114] - Successfully authenticated client: authenticationID=bob; authorizationID=bob.
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:SaslServerCallbackHandler@130] - Setting authorizedID: bob
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:ZooKeeperServer@934] - adding SASL authorization for authorizationID: bob
[...]
[myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@466] - Processed session termination for sessionid: 0x136b09915f00009
[myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2183:NIOServerCnxn@1000] - Closed socket connection for client /127.0.0.1:54398 which had sessionid 0x136b09915f00009
The node is actually created but after that the client hangs.
Also If I use another client as watcher like:
System.setProperty("java.security.auth.login.config","C:\apps\zookeeper-3.4.3\client_jaas.conf");
[...]
CuratorFramework client = CuratorFrameworkFactory.newClient("127.0.0.1:2183", new RetryNTimes(10, 1000));
client.start();
final PathChildrenCache cache = new PathChildrenCache(client, "/path", true);
cache.getListenable().addListener(new PathChildrenCacheListener() {
@OverRide
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event)
throws Exception {
System.out.println("event: " + event.getType());
System.out.println("data: " + new String(event.getData().getData()));
}
});
it hangs as well and doesn't get any event. After the retry loop ends it gets the ConnectionLossException too.
If I remove the java.security.policy config file setting and the authProvide everything works fine.
Thanks
Antonio