0

My config file:

global
    maxconn     4096 # Total Max Connections. This is dependent on ulimit
    nbproc      2
    daemon
    log         127.0.0.1    local1 notice
defaults
    mode        http

frontend all 0.0.0.0:80
    timeout client 86400000
    default_backend www_backend
    acl is_websocket hdr(Upgrade) -i WebSocket
    acl is_websocket hdr_beg(Host) -i ws
    acl is_websocket path_beg /socket.io

    use_backend socket_backend if is_websocket

backend www_backend
    balance roundrobin
    option forwardfor # This sets X-Forwarded-For
    timeout server 30000
    timeout connect 4000
    server server1 localhost:9001 weight 1 maxconn 1024 check
    server server2 localhost:9002 weight 1 maxconn 1024 check

backend socket_backend
    balance roundrobin
    option forwardfor # This sets X-Forwarded-For
    stats enable
    timeout queue 5000
    timeout server 86400000
    timeout connect 86400000
    server server1 localhost:5000 weight 1 maxconn 1024 check

As far as I can tell www_backend matches everything. When my web app requests http://myapp.com/socket.io/1/?t=1335831853491 it returns a 404, and the header shows the response came from Express. The odd thing is when I do curl -I http://myapp.com/socket.io/1/?t=1335831853491 it returns:

HTTP/1.1 200 OK
Content-Type: text/plain
Connection: keep-alive

When I run sudo netstat -lptu I can confirm that my socket.io process is running on port 5000. Any thoughts?

LDK
  • 2,555
  • 5
  • 27
  • 40

2 Answers2

1

Answer found here:

https://serverfault.com/questions/248897/haproxy-access-list-using-path-dir-having-issues-with-firefox

"ust add "option http-server-close" to your defaults section and it should work."

Community
  • 1
  • 1
LDK
  • 2,555
  • 5
  • 27
  • 40
1

Agreed with the response above. BTW, you should not use a 1-day timeout for the TCP connection to establish (timeout connect), it makes no sense at all and will cause connections to accumulate when your server goes down. A connection (especially a local one) is supposed to establish immediately. I tend to set a 5s timeout for connect, which is far enough even across slow networks.

Concerning the other long timeouts, I'm planning on implementing a "timeout tunnel" so that users don't have to use that large timeouts for normal traffic.

Willy Tarreau
  • 3,384
  • 1
  • 17
  • 11
  • Willy, the 1-day timeout seems to be the encouraged for socket.io http://stackoverflow.com/questions/4360221/haproxy-websocket-disconnection/4737648#4737648 . Perhaps posting there and https://github.com/learnboost/socket.io/wiki/ might help others not make the same mistake I did! Thanks for your help by the way. – LDK May 06 '12 at 14:40