Can';t使用marathon lb访问websocket(ws://)url

Can';t使用marathon lb访问websocket(ws://)url,websocket,jupyter,haproxy,mesos,marathon,Websocket,Jupyter,Haproxy,Mesos,Marathon,我有一个运行jupyter网关的容器,它需要两个url来访问http和websocket url 例如,在localhost上,这些URL是http://127.0.0.1:8888和ws://127.0.0.1:8888 当我用marathon和ssh启动我的应用程序进入运行容器的mesos从机时,我可以使用向jupyter网关发出请求的客户端访问这两个url功能。这告诉我容器中的jupyter网关工作正常 然而,当我试图通过marathon负载平衡器访问jupyter网关时,我的客户端告诉我

我有一个运行jupyter网关的容器,它需要两个url来访问http和websocket url

例如,在localhost上,这些URL是
http://127.0.0.1:8888
ws://127.0.0.1:8888

当我用marathon和ssh启动我的应用程序进入运行容器的mesos从机时,我可以使用向jupyter网关发出请求的客户端访问这两个url功能。这告诉我容器中的jupyter网关工作正常

然而,当我试图通过marathon负载平衡器访问jupyter网关时,我的客户端告诉我它可以访问
http://
url,但当我试图连接到我需要访问的
ws://
url时,它会超时

我相信marathon lb支持转发WebSocket而无需额外配置,因此我不确定问题出在哪里,但我怀疑它可能与我的marathon应用程序标签中的以下haproxy配置有关

标签:

HAPROXY_0_MODE=http
HAPROXY_0_PATH=/jupyter-gateway-container-path
HAPROXY_0_VHOST=ourwebsite.com
编辑以添加更多日志:

下面是客户端和服务器日志。服务器是Jupyter网关。客户机是他们在示例存储库中提供的python客户机。您可以看到,一个https://请求从客户端成功通过,它在服务器的日志中显示了一个201 POST。但是ws://请求超时了

  $ python client.py
https://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1
ws://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1
Created kernel 11e9b48b-d0b9-4419-b13a-205eaee7f2c7. Connect other clients with the following command:
            docker-compose run client --kernel-id=11e9b48b-d0b9-4419-b13a-205eaee7f2c7

ws://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1/api/kernels/11e9b48b-d0b9-4419-b13a-205eaee7f2c7/channels
Traceback (most recent call last):
  File "client.py", line 178, in <module>
    IOLoop.current().run_sync(main)
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 453, in run_sync
    return future_cell[0].result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "client.py", line 125, in main
    ws = yield websocket_connect(ws_req)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 599: Timeout
客户端日志https://请求正常,但ws://超时

  $ python client.py
https://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1
ws://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1
Created kernel 11e9b48b-d0b9-4419-b13a-205eaee7f2c7. Connect other clients with the following command:
            docker-compose run client --kernel-id=11e9b48b-d0b9-4419-b13a-205eaee7f2c7

ws://<websitename>.io/7c5e1967-b8e4-4e6d-bb68-80881d7f3de1/api/kernels/11e9b48b-d0b9-4419-b13a-205eaee7f2c7/channels
Traceback (most recent call last):
  File "client.py", line 178, in <module>
    IOLoop.current().run_sync(main)
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 453, in run_sync
    return future_cell[0].result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "client.py", line 125, in main
    ws = yield websocket_connect(ws_req)
  File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
tornado.httpclient.HTTPError: HTTP 599: Timeout

很可能您遇到了端口正确检查的问题,因此您需要以下内容:

"HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "  option  httpchk GET {healthCheckPath}
 HTTP/1.1\\r\\nHost:\\ www\n
  timeout check {healthCheckTimeoutSeconds}s\n",
"HAPROXY_1_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "  option  httpchk GET {healthCheckPath}
 HTTP/1.1\\r\\nHost:\\ www\n
  timeout check {healthCheckTimeoutSeconds}s\n",
"HAPROXY_HTTP_FRONTEND_ACL": "  acl host_{cleanedUpHostname} hdr(host) -i {hostname}\\r\\n
  use_backend {backend} if host_{cleanedUpHostname}\\r\\n
  acl is_websocket hdr(Upgrade) -i WebSocket\\r\\n
  use_backend {backend} if is_websocket"
注意HAPROXY_0和HAPROXY_1,您需要为应用程序中定义的每个端口配置它

要使WebSocket真正运行,您需要确保已识别连接:

acl is_websocket hdr(Upgrade) -i WebSocket
use_backend {backend} if is_websocket
在应用程序的上下文中,您需要按照以下方式对其进行配置:

"HAPROXY_0_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "  option  httpchk GET {healthCheckPath}
 HTTP/1.1\\r\\nHost:\\ www\n
  timeout check {healthCheckTimeoutSeconds}s\n",
"HAPROXY_1_BACKEND_HTTP_HEALTHCHECK_OPTIONS": "  option  httpchk GET {healthCheckPath}
 HTTP/1.1\\r\\nHost:\\ www\n
  timeout check {healthCheckTimeoutSeconds}s\n",
"HAPROXY_HTTP_FRONTEND_ACL": "  acl host_{cleanedUpHostname} hdr(host) -i {hostname}\\r\\n
  use_backend {backend} if host_{cleanedUpHostname}\\r\\n
  acl is_websocket hdr(Upgrade) -i WebSocket\\r\\n
  use_backend {backend} if is_websocket"

这里还要注意,我确保默认配置仍然可用,因此其他所有配置都可以作为默认配置使用,但也可以使用WebSocket

您可以从客户端和服务器附加一些日志吗?你有没有看到我已经附加了客户端和服务器日志。这篇文章似乎很相关,但我正在与marathon lb合作,它会自动生成haproxy confing。因此,我需要了解如何配置marathon lb来配置haproxy以支持代理websocket连接。还值得注意的是,我可以在本地使用容器,只有一个端口打开8888,因此我不确定这是否意味着http和ws连接都要经过该端口。因此我有
“HAPROXY\u 0\u http\u FRONTEND\u ACL”:“ACL host{cleanedUpHostname}hdr(host)-I{hostname}\\\r\\\n如果host{cleanedUpHostname},请使用{backend}backend}\\\\r\\\\n acl是\u websocket hdr(升级)-i websocket\\\\r\\\\n如果是\u websocket“
此标签,则使用\u backend{backend},但不会在haproxy配置文件中进行更改。