无法通过 haproxy 负载平衡 Socket.io 请求

Not able to Load Balance Socket.io request over haproxy

我正在尝试使用 HAProxy 对 socket.io 请求进行负载平衡。以下是我的配置:

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000

frontend all 0.0.0.0:8888
    mode http
    timeout client 120s

    option forwardfor
    # Fake connection:close, required in this setup.
    option http-server-close
    option http-pretend-keepalive

    acl is_socketio path_beg /socket.io

    use_backend socket-servers if is_socketio
    default_backend http-servers


backend http-servers
    balance roundrobin
    option httpclose
    option forwardfor

    # Roundrobin switching
    server node-1 172.14.2.25:8887 check
    server node-2 172.14.2.28:8887 check


backend socket-servers
    mode http
    timeout server  120s
    balance roundrobin
    # based on cookie set in header
    # haproxy will add the cookies for us
    option forwardfor
    cookie SERVERID insert indirect nocache
    server node1 172.14.2.25:8887 cookie node1 weight 1 maxconn 1024 check
    server node2 172.14.2.28:8887 cookie node2 weight 1 maxconn 1024 check

此配置在我尝试创建套接字连接时超时。

但是,如果我删除最后两行中的任何一行 [server node1 172.14.2.25:8887 cookie node1 weight 1 maxconn 1024 checkserver node2 172.14.2.28:8887 cookie node2 weight 1 maxconn 1024 check],套接字连接正常。

我不明白配置有什么问题。任何帮助将不胜感激。

TIA :)

backend socket-servers 的配置中,我不得不将 balance roundrobin 更改为 balance source。成功了! :)