Error: connect ECONNREFUSED
Closed this issue · 2 comments
Hi,
Fantastic work on this, it looks brilliant!
It's probably my complete lack of knowledge re: node.js, but I couldn't get it to work :-(
[root@localhost:~/ha-api]$ ../node-v0.10.28-linux-x64/bin/node
> var HAApi= require('./ha-api'),
... haapi = new HAApi({
... socket: { socket : '/var/lib/haproxy/stats' },
... apiPort : 1111
... })
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
undefined
>
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19)
Exit 8
I've confirmed that HAProxy's socket is working as expected. Eg.
echo 'disable server webfarm/server1' | socat stdio /var/lib/haproxy/stats
Results in that server marked as disabled in the HAProxy stats web UI.
Can you help? Thanks in advance!
Hi,
this is intended to be used with tcp sockets, not with unix sockets (like you did : socket : '/var/lib/haproxy/stats').
The socket declaration in the HAproxy conf file should loog like this :
stats socket ipv4@0.0.0.0:7001 level admin
And your initialization should look like
haapi = new HAApi({
host : 'haproxymachine',
port : 7001
})
Ah! Sorry, I spotted a mention in the docs of using a unix socket, but didn't think to try tcp! Thanks for the quick response and the great project :)