Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCP transporter IP bug #380

Closed
0x39 opened this issue Sep 22, 2018 · 5 comments
Closed

TCP transporter IP bug #380

0x39 opened this issue Sep 22, 2018 · 5 comments

Comments

@0x39
Copy link

0x39 commented Sep 22, 2018

I'm testing TCP transporter.
All nodes is docker containers managed by rancher.

Transporter configuration, kind:

nodeID: 'node-id-1',
transporter: {
        type: 'TCP',
        options: {
            udpDiscovery: false,
            useHostname: true, //have tried true/false
            urls: [
               container_hostname:6000/node-id-1,
               ...
            ],
        }
    }

Problem is when i upgrade my rancher service, container IP changes, but all moleculer nodes still try to use old IP.

Some logs: https://gist.github.com/0x39/25bcf691268858155f8efeb210651ce8

screenshot from 2018-09-23 01 11 32

@icebob
Copy link
Member

icebob commented Nov 1, 2018

Does somebody have an idea how we can force NodeJS to resolve again DNS names?

@zllovesuki
Copy link
Contributor

zllovesuki commented Nov 6, 2018

I think the native DNS bingings will respect the TTL. It will resolve again if the TTL expires. There's no way to "force" hostname to resolve again without using third-party modules.


Consider using service discovery like etcd or consul. Relying on container dns name resolution is inherently broken. If you are using networked transporter (such as gnatsd or Redis) then initial service discovery is built-in to the transporter. Using TCP introduces nuisance where you don't know where your other peers are (in fact, projects like cote will recommend you to use Redis as a "service discovery" repo for that matter), thus external initial discovery is needed. Then gossip takes care of the rest.

@zllovesuki
Copy link
Contributor

zllovesuki commented Nov 7, 2018

As a last resort, you could have an empty moleculer service (with unchanging hostname) which acts an introducer/arbitrator/middle man, then all your other instances should have random hostnames, and use the empty service as the entry point.

#notabug

@Wallacy
Copy link
Contributor

Wallacy commented Nov 9, 2018

I did not try but using dns.resolve4(hostname[, options], callback) passing a low ttl under options solve the problem? https://nodejs.org/api/dns.html

@icebob
Copy link
Member

icebob commented Nov 10, 2018

The docs say the ttl in option is a boolean. If true, the callback returns the TTL setting. So you can't use it to define TTL for DNS resolving.

@icebob icebob closed this as completed Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants