stianeikeland / node-etcd

:satellite: Etcd client for nodejs
BSD 3-Clause "New" or "Revised" License
259 stars 85 forks source link

auto add port #55

Closed shenshouer closed 8 years ago

shenshouer commented 8 years ago

code:

function Watch(etcd_endpoint, name){
    console.log("etcd_endpoint",etcd_endpoint, "name",name);
    this.cacheEtcd = new Etcd(etcd_endpoint);
    this.name = name;
    this.etcdDir = '/load_balancer/swarm/'+name;
}

var watcher = new Watch("10.11.3.26:3379", "swarm-6");

watcher.delFailedService(function(){});

error:

{ Error: All servers returned error
    at Client._error (/wk/test/node_modules/node-etcd/lib/client.js:191:13)
    at Client._multiserverHelper (/wk/test/node_modules/node-etcd/lib/client.js:118:19)
    at Client._multiserverHelper (/wk/test/node_modules/node-etcd/lib/client.js:3:57)
    at Request._callback (/wk/test/node_modules/node-etcd/lib/client.js:134:24)
    at self.callback (/wk/test/node_modules/request/request.js:198:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/wk/test/node_modules/request/request.js:861:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
  errors:
   [ { server: 'http://10.11.3.26:3379:4001',
       httperror: [Object],
       httpstatus: undefined,
       httpbody: undefined,
       response: undefined,
       timestamp: 2016-05-18T05:54:42.151Z } ],
  retries: 0 }
pmoust commented 8 years ago

Yeap, same issue here. Default port nowadays is 2379. Your package auto-appends :4001

shenshouer commented 8 years ago

So is there any way to solve this?

fluciotto commented 8 years ago

When you use the constructor with an array of etcd endpoints, the default 4001 port won't be added.

this.cacheEtcd = new Etcd(etcd_endpoint); becomes this.cacheEtcd = new Etcd([etcd_endpoint]);

pmoust commented 8 years ago

makes sense, ty.

stianeikeland commented 8 years ago

Thank you. I've released v5.0.x, it changes default port to 2379.