admin管理员组文章数量:1405574
I have a docker compose stack that includes ZooKeeper. It has worked beautifully for years.
zoo:
container_name: zoo
image: public.ecr.aws/docker/library/zookeeper:3.9.3
restart: unless-stopped
stdin_open: true
tty: true
I have Java and Ruby clients connect to ZooKeeper using zoo:2181
as a connection string.
I am now running this same container in AWS ECS. I am using a ServiceConnectConfiguration to make the container discoverable with the name "zoo".
My Ruby client seems to have no issue connecting to ZooKeeper.
My Java client is very unreliable if I use the ServiceConnect name.
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
| Exception .apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
| at KeeperException.create (KeeperException.java:101)
| at KeeperException.create (KeeperException.java:53)
| at ZooKeeper.getChildren (ZooKeeper.java:2366)
| at ZooKeeper.getChildren (ZooKeeper.java:2393)
| at (#9:2)
If I use the ip address for "zoo" from /etc/hosts, I have no trouble connecting.
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
I am unsure if I need to fix this in the ServiceConnect configuration or if I can configure my ZooKeeper service to to function more effectively in this environment.
Looking at the services in ECS, there seems to be sufficient memory or CPU for the running tasks.
I have a docker compose stack that includes ZooKeeper. It has worked beautifully for years.
zoo:
container_name: zoo
image: public.ecr.aws/docker/library/zookeeper:3.9.3
restart: unless-stopped
stdin_open: true
tty: true
I have Java and Ruby clients connect to ZooKeeper using zoo:2181
as a connection string.
I am now running this same container in AWS ECS. I am using a ServiceConnectConfiguration to make the container discoverable with the name "zoo".
My Ruby client seems to have no issue connecting to ZooKeeper.
My Java client is very unreliable if I use the ServiceConnect name.
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
| Exception .apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
| at KeeperException.create (KeeperException.java:101)
| at KeeperException.create (KeeperException.java:53)
| at ZooKeeper.getChildren (ZooKeeper.java:2366)
| at ZooKeeper.getChildren (ZooKeeper.java:2393)
| at (#9:2)
If I use the ip address for "zoo" from /etc/hosts, I have no trouble connecting.
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "127.255.0.10", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, locks, jobs]
I am unsure if I need to fix this in the ServiceConnect configuration or if I can configure my ZooKeeper service to to function more effectively in this environment.
Looking at the services in ECS, there seems to be sufficient memory or CPU for the running tasks.
Share Improve this question asked Mar 21 at 17:59 terrywbterrywb 3,9764 gold badges27 silver badges57 bronze badges1 Answer
Reset to default 0Forcing traffic to IPv4 seems to have resolved this issue.
bash-4.2# jshell -R -Djava.preferIPv4Stack=true
| Welcome to JShell -- Version 21.0.6
| For an introduction type: /help intro
jshell> import .apache.zookeeper.ZooKeeper;
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, jobs]
jshell> try (ZooKeeper zk = new ZooKeeper(String.format("%s:%d", "zoo", 2181), 5000, null)){
...> System.out.println(zk.getChildren("/",false));
...> }
[batches, zookeeper, batch-uuids, jobs]
本文标签:
版权声明:本文标题:amazon ecs - ZooKeeper with ECS ServiceConnect: ConnectionLossException: KeeperErrorCode = ConnectionLoss - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744340792a2601462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论