Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i'm still with dealing with the configuration of HAproxy to make it work with socket.io.

my last question was this: HAProxy is caching the forwarding? and i got it working, but for some reason, after the authentication is made and the some commands are sent, the connection is dropped and a new connection is made as you can see here:

  info  - handshake authorized 2ZqGgU2L5RNksXQRWuhi
  debug - setting request GET /socket.io/1/websocket/2ZqGgU2L5RNksXQRWuhi
  debug - set heartbeat interval for client 2ZqGgU2L5RNksXQRWuhi
  debug - client authorized for 
  debug - websocket writing 1::
  debug - websocket received data packet 5:3+::{"name":"ferret","args":["tobi"]}
  debug - sending data ack packet
  debug - websocket writing 6:::3+["woot"]
  info  - transport end (socket end)
  debug - set close timeout for client 2ZqGgU2L5RNksXQRWuhi
  debug - cleared close timeout for client 2ZqGgU2L5RNksXQRWuhi
  debug - cleared heartbeat interval for client 2ZqGgU2L5RNksXQRWuhi
  debug - discarding transport
  debug - client authorized
  info  - handshake authorized WkHV-B80ejP6MHQTWuhj
  debug - setting request GET /socket.io/1/websocket/WkHV-B80ejP6MHQTWuhj
  debug - set heartbeat interval for client WkHV-B80ejP6MHQTWuhj
  debug - client authorized for 
  debug - websocket writing 1::
  debug - websocket received data packet 5:4+::{"name":"ferret","args":["tobi"]}
  debug - sending data ack packet
  debug - websocket writing 6:::4+["woot"]
  info  - transport end (socket end)

i tried several configurations, something like this: http://stackoverflow.com/questions/4360221/haproxy-websocket-disconnection/

and also declaring 2 backends, and using ACL to forward to a backend that has the option http-pretend-keepalive when the request is a websocket request and to a backend that has http-server-close when the request is only for socket.io static files or is any other type of request that is not websocket.

i would clarify that http-server-close is only on the nginx backend and in the static files backend, http-pretend-keepalive is on frontend all and in the websocket backend.

anyone could point me to the right direction? i tried several combinations and none worked so far :(

share|improve this question

1 Answer 1

up vote 1 down vote accepted

got an answer from the HAproxy mailling list, where an user called "Baptiste" give me this link:

http://blog.exceliance.fr/2012/11/07/websockets-load-balancing-with-haproxy/

that configuration works perfectly with socket.io (tested with all the protocols except flashsockets). What make it works is the set of options in the default directive, the checks for websockets in the backends and the headers checks are not really needed and you can set your own ACL to whatever you need to decide if you use the backend that is executing the socket.io app or not.

The stable version of HAproxy doesn't work with this config, you need a 1.5-devel10 or newer to have it working (i used the 1.5-devel14 version).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.