Ballon Ura
Ballon Ura

Reputation: 922

Node.js dns.lookup() to internal docker-compose service

I've try yo measure DNS latency in my docker-compose/kubernetes cluster.

  setInterval(() => {
    console.time('dns-test');

    dns.lookup('http://my-service', (_, addresses, __) => {
      console.log('addresses:', addresses);
      console.timeEnd('dns-test');
    });
  }, 5000);

But get addresses: undefined, any ideas?

Upvotes: 0

Views: 224

Answers (1)

gohm'c
gohm'c

Reputation: 15530

...dns.lookup('http://my-service'...

The lookup function (with example usage) takes the first parameter as the host name that you want to lookup, eg. google.com. You should remove "http://" from the name you passed in.

Upvotes: 2

Related Questions