【发布时间】:2017-10-16 06:21:40
【问题描述】:
我有一个运行 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:// 请求超时。
客户端日志 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
服务器日志收到 https 请求正常,没有提及进一步的连接。
[KernelGatewayApp] Jupyter Kernel Gateway at http://0.0.0.0:8888
[KernelGatewayApp] Kernel started: 11e9b48b-d0b9-4419-b13a-205eaee7f2c7
[I 170519 01:12:22 web:1971] 201 POST /7c5e1967-b8e4-4e6d-bb68-80881d7f3de1/api/kernels (10.0.0.173) 35.77ms
【问题讨论】:
-
你能附上一些来自客户端和服务器的日志吗?你见过websockets load balancing with haproxy
-
我已附上客户端和服务器日志。那篇文章似乎很相关,但我正在使用 marathon-lb 自动生成 haproxy confing。所以我需要了解如何配置 marathon-lb 来配置 haproxy 以支持代理 websocket 连接。还值得注意的是,我可以在本地使用容器,只打开一个端口 8888,所以我不确定这是否意味着 http 和 ws 连接都通过那个端口。
标签: websocket jupyter haproxy mesos marathon