question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected error occurred: cannot find a NameResolver for ip:///localhost:2379

See original GitHub issue

Hello,

Description

Playing with this project I’ve tried to do the hello world but unfortunately, the client code is not able to reach the etcd server (localhost)

Unexpected error occurred: cannot find a NameResolver for ip:///localhost:2379

It looks like my code is not able to reach the etcd server working as a Docker container when my local etcdctl actually can connect. I’m doing it all in localhost.

How do I run the etcd server?

$ docker run -it --rm -p 2379:2379 -p 4001:4001 --name myetcd quay.io/coreos/etcd:v3.4.9 /usr/local/bin/etcd -advertise-client-urls http://0.0.0.0:2379 -listen-client-urls http://0.0.0.0:2379
[WARNING] Deprecated '--logger=capnslog' flag is set; use '--logger=zap' flag instead
2020-11-25 10:47:39.497586 I | etcdmain: etcd Version: 3.4.9
2020-11-25 10:47:39.497648 I | etcdmain: Git SHA: 54ba95891
2020-11-25 10:47:39.497663 I | etcdmain: Go Version: go1.12.17
2020-11-25 10:47:39.497671 I | etcdmain: Go OS/Arch: linux/amd64
2020-11-25 10:47:39.497680 I | etcdmain: setting maximum number of CPUs to 4, total number of available CPUs is 4
2020-11-25 10:47:39.497694 W | etcdmain: no data-dir provided, using default data-dir ./default.etcd
[WARNING] Deprecated '--logger=capnslog' flag is set; use '--logger=zap' flag instead
2020-11-25 10:47:39.499005 I | embed: name = default
2020-11-25 10:47:39.499025 I | embed: data dir = default.etcd
2020-11-25 10:47:39.499051 I | embed: member dir = default.etcd/member
2020-11-25 10:47:39.499070 I | embed: heartbeat = 100ms
2020-11-25 10:47:39.499089 I | embed: election = 1000ms
2020-11-25 10:47:39.499117 I | embed: snapshot count = 100000
2020-11-25 10:47:39.499143 I | embed: advertise client URLs = http://0.0.0.0:2379
2020-11-25 10:47:39.508815 I | etcdserver: starting member 8e9e05c52164694d in cluster cdf818194e3a8c32
raft2020/11/25 10:47:39 INFO: 8e9e05c52164694d switched to configuration voters=()
raft2020/11/25 10:47:39 INFO: 8e9e05c52164694d became follower at term 0
raft2020/11/25 10:47:39 INFO: newRaft 8e9e05c52164694d [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]
raft2020/11/25 10:47:39 INFO: 8e9e05c52164694d became follower at term 1
raft2020/11/25 10:47:39 INFO: 8e9e05c52164694d switched to configuration voters=(10276657743932975437)
2020-11-25 10:47:39.513242 W | auth: simple token is not cryptographically signed
2020-11-25 10:47:39.521558 I | etcdserver: starting server... [version: 3.4.9, cluster version: to_be_decided]
2020-11-25 10:47:39.522034 I | etcdserver: 8e9e05c52164694d as single-node; fast-forwarding 9 ticks (election ticks 10)
raft2020/11/25 10:47:39 INFO: 8e9e05c52164694d switched to configuration voters=(10276657743932975437)
2020-11-25 10:47:39.522848 I | etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32
2020-11-25 10:47:39.524131 I | embed: listening for peers on 127.0.0.1:2380
raft2020/11/25 10:47:40 INFO: 8e9e05c52164694d is starting a new election at term 1
raft2020/11/25 10:47:40 INFO: 8e9e05c52164694d became candidate at term 2
raft2020/11/25 10:47:40 INFO: 8e9e05c52164694d received MsgVoteResp from 8e9e05c52164694d at term 2
raft2020/11/25 10:47:40 INFO: 8e9e05c52164694d became leader at term 2
raft2020/11/25 10:47:40 INFO: raft.node: 8e9e05c52164694d elected leader 8e9e05c52164694d at term 2
2020-11-25 10:47:40.110936 I | etcdserver: setting up the initial cluster version to 3.4
2020-11-25 10:47:40.112290 N | etcdserver/membership: set the initial cluster version to 3.4
2020-11-25 10:47:40.112421 I | etcdserver/api: enabled capabilities for version 3.4
2020-11-25 10:47:40.112521 I | etcdserver: published {Name:default ClientURLs:[http://0.0.0.0:2379]} to cluster cdf818194e3a8c32
2020-11-25 10:47:40.112853 I | embed: ready to serve client requests
2020-11-25 10:47:40.114584 N | embed: serving insecure client requests on [::]:2379, this is strongly discouraged!

Does the etcd work with the etcdctl?

Yes,

$ etcdctl put foo bar --endpoints=localhost:2379
OK
$ etcdctl get foo --endpoints=192.168.1.43:2379
foo
bar

The code I’m using

# MyController.java
...
Client client = Client.builder().endpoints("http://0.0.0.0:2379").build();
KV kvClient = client.getKVClient();
...

What is the stack trace error

Unexpected error occurred: cannot find a NameResolver for ip:///0.0.0.0:2379
java.lang.IllegalArgumentException: cannot find a NameResolver for ip:///0.0.0.0:2379
        at io.grpc.internal.ManagedChannelImpl.getNameResolver(ManagedChannelImpl.java:744)
        at io.grpc.internal.ManagedChannelImpl.<init>(ManagedChannelImpl.java:633)
        at io.grpc.internal.ManagedChannelImplBuilder.build(ManagedChannelImplBuilder.java:596)
        at io.grpc.ForwardingChannelBuilder.build(ForwardingChannelBuilder.java:255)
        at io.etcd.jetcd.ClientConnectionManager.getChannel(ClientConnectionManager.java:123)
        at io.etcd.jetcd.ClientConnectionManager.newStub(ClientConnectionManager.java:172)
        at io.etcd.jetcd.KVImpl.<init>(KVImpl.java:54)
        at io.etcd.jetcd.ClientImpl.lambda$new$0(ClientImpl.java:38)
        at io.etcd.jetcd.support.MemoizingClientSupplier.get(MemoizingClientSupplier.java:37)
        at io.etcd.jetcd.ClientImpl.getKVClient(ClientImpl.java:55)
        at com.marcosflobo.micronaut.etcd.demo.MyController.get(MyController.java:35)

What else I’ve tried

  • Instead of http://localhost:2379, I’ve tried with http://0.0.0.0:2379, http://127.0.0.1:2379, http://$MYLOCALIP:2379, localhost:2379

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lburgazzolicommented, Nov 25, 2020

it depends what shadow does, if it rename classes, then you also need to rename the service files

1reaction
lburgazzolicommented, Nov 25, 2020

That seems quite strange as the resolver should be part of jetcd-core jar. Can you share more info about the project set-up, dependencies etc ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot find a NameResolver exception for revision ... - GitHub
Something is going wrong while trying to load name resolvers, specifically the DNS resolver. This is done using ServiceLoader in the JDK, which ......
Read more >
gRPC Java cannot find a NameResolver when using in OSGi ...
When I debug the gRPC code at runtime I can see that there is zero NameResolvers added. I think that this can be...
Read more >
NameResolver (grpc-all 1.51.0 API)
A pluggable component that resolves a target URI and return addresses to the caller. A NameResolver uses the URI's scheme to determine whether...
Read more >
[grpc-java] using NameResolver for grpc servers with TLS
Basically in the client I am creating a channel. ... The error is caused by my NameResolver implementation returning the service id as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found