【问题标题】:HAProxy/Websockets why new sockets are constantly being created?HAProxy/Websockets 为什么不断创建新的套接字?
【发布时间】:2013-01-21 15:44:43
【问题描述】:

我正在尝试使用 HAProxy 设置 Websockets,配置如下: http 流量 -> haproxy -> varnish -> nginx -> 节点 ws 流量 -> haproxy -> 节点

一个子域强制使用 ssl,因此 haproxy 将任何 http 流量重定向到 https。 (和 ws 到 wss)

除了一个问题外,一切都按预期工作,不断创建新套接字而不是一个(我可以在 Chrome 的调试控制台中看到它们每隔几秒创建一次)

我用 Varnish 做 Websockets 管道的时候没有这个问题。

我该如何解决这个问题?

global
  daemon

defaults
  mode  http

frontend insecure
 # HTTP
  bind :80

  timeout client 5000

  # acl
  acl is_console hdr_end(host) -i console.mydomain.com
  acl is_client hdr_end(host) -i www.mydomain.com
  acl is_websocket hdr(Upgrade) -i WebSocket
  acl is_websocket hdr_beg(Host) -i ws

  # Redirect all HTTP traffic to HTTPS
  redirect location https://console.mydomain.com if is_console

  use_backend node_console if is_console is_websocket
  use_backend node_client if is_client is_websocket
  default_backend varnish

frontend secure
 # HTTPS
  bind :443 ssl crt /etc/ssl/console.mydomain.com.pem

  timeout client 5000

  # acl
  acl is_console hdr_end(host) -i console.mydomain.com
  acl is_client hdr_end(host) -i www.mydomain.com
  acl is_websocket hdr(Upgrade) -i WebSocket
  acl is_websocket hdr_beg(Host) -i ws

  use_backend dealspot_console if is_console is_websocket
  use_backend dealspot_client if is_client is_websocket
  default_backend varnish

backend varnish
  balance leastconn
  option forwardfor
  timeout server 5000
  timeout connect 4000
  server varnish1 127.0.0.1:6081

backend node_client
  balance leastconn
  option forwardfor
  timeout queue 5000
  timeout server 5000
  timeout connect 5000
  server client_node1 127.0.0.1:3000

backend node_console
  balance leastconn
  option forwardfor
  timeout queue 5000
  timeout server 5000
  timeout connect 5000
  server console_node1 127.0.0.1:3001

【问题讨论】:

    标签: node.js socket.io haproxy


    【解决方案1】:

    我设法通过在后端将“隧道超时”设置为一天来解决这个问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-17
      • 1970-01-01
      • 2017-01-08
      • 2011-10-13
      相关资源
      最近更新 更多