0

我无法理解 jupyter 仪表板服务器的哪个部分不起作用。看起来仪表板服务器正在工作,内核网关正在工作并且内核启动,但由于某种原因,在启动后,到内核的 websocket 流量得到 404 作为响应。

我尝试在内核网关上发出 curl 请求,但 curl 不支持“ws”协议。

我该如何进一步调试呢?下面的所有细节。

我有一个带有这个 Apache 配置的虚拟机(debian jessie):

ProxyPreserveHost on
ProxyPass "/" "http://127.0.0.1:3000/"
ProxyPassReverse "/" "http://127.0.0.1:3000/"

我有仪表板服务器,它正在响应:

GET /dashboards/Environment_variables 200 39.408 ms - 2400
GET /css/style.css 200 1.688 ms - 186626
GET /components/require.js 200 3.943 ms - 86262
GET /components/dashboard.js 200 1.351 ms - 788654
GET /components/fonts/fontawesome-webfont.woff2?v=4.6.3 304 0.689 ms - -
GET /components/dashboard.js.map 304 0.621 ms - -
POST /api/kernels?1475506860562 201 923.933 ms - 62
GET /api/kernels/d7681c2f-b8f9-4b19-9893-6bd6022d0e77/channels?session_id=ad17021f13dd752eb2e687b4a78fee64 404 2.936 ms - 1021
GET /api/kernels/d7681c2f-b8f9-4b19-9893-6bd6022d0e77/channels?session_id=ad17021f13dd752eb2e687b4a78fee64 404 3.703 ms - 1021

尽管最后是404。

然后我运行内核网关:

[KernelGatewayApp] The Jupyter Kernel Gateway is running at: http://127.0.0.1:8888
[KernelGatewayApp] Native kernel (python3) available from /opt/anaconda3/lib/python3.5/site-packages/ipykernel/resources
[KernelGatewayApp] Starting kernel: ['/opt/anaconda3/bin/python', '-m', 'ipykernel', '-f', '/home/sandman/.local/share/jupyter/runtime/kernel-d7681c2f-b8f9-4b19-9893-6bd6022d0e77.json']
[KernelGatewayApp] Connecting to: tcp://127.0.0.1:52565
[KernelGatewayApp] Kernel started: d7681c2f-b8f9-4b19-9893-6bd6022d0e77
[KernelGatewayApp] Kernel args: {'kernel_name': 'python3'}
[I 161003 16:01:01 web:1971] 201 POST /api/kernels (127.0.0.1) 917.05ms

它看到了对内核的请求,据我所知,它启动了它。

但是浏览器看不到它:

Environment_variables   200 document    Other   1.2 KB  365 ms  
style.css   200 stylesheet  Environment_variables:7 29.2 KB 259 ms  
require.js  200 script  Environment_variables:64    21.0 KB 325 ms  
dashboard.js    200 script  Environment_variables:65    214 KB  989 ms  
fontawesome-webfont.woff2?v=4.6.3   304 font    Environment_variables:64    216 B   82 ms   
kernels?1475506860562   201 xhr index.js:178    395 B   1.01 s  
cursor.png  200 png middlemouse.js:53   (from cache)    2 ms    
channels?session_id=ad17021f13dd752eb2e687b4a78fee64    404 websocket   Other   0 B 82 ms   
channels?session_id=ad17021f13dd752eb2e687b4a78fee64    404 websocket   Other   0 B 82 ms   

在此处输入图像描述

我还尝试以 http 模式启动内核网关,但这只是给了我一个错误:

$ jupyter kernelgateway --KernelGatewayApp.api=kernel_gateway.notebook_http --debug
Traceback (most recent call last):
  File "/opt/anaconda3/bin/jupyter-kernelgateway", line 11, in <module>
    sys.exit(launch_instance())
  File "/opt/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 652, in launch_instance
    app.initialize(argv)
  File "/opt/anaconda3/lib/python3.5/site-packages/kernel_gateway/gatewayapp.py", line 298, in initialize
    self.init_configurables()
  File "/opt/anaconda3/lib/python3.5/site-packages/kernel_gateway/gatewayapp.py", line 352, in init_configurables
    self.personality = func(parent=self, log=self.log)
  File "/opt/anaconda3/lib/python3.5/site-packages/kernel_gateway/notebook_http/__init__.py", line 144, in create_personality
    return NotebookHTTPPersonality(*args, **kwargs)
  File "/opt/anaconda3/lib/python3.5/site-packages/kernel_gateway/notebook_http/__init__.py", line 25, in __init__
    self.api_parser = func(parent=self, log=self.log, kernelspec=self.parent.kernel_manager.seed_kernelspec, notebook_cells=self.parent.seed_notebook.cells)
AttributeError: 'NoneType' object has no attribute 'cells'
4

1 回答 1

1

弄清楚了。

    ProxyPreserveHost on

    ProxyPassMatch "/api/kernels/(.*)/channels" "ws://127.0.0.1:3000/api/kernels/$1/channels"
    ProxyPassReverse "/api/kernels" "ws://127.0.0.1:3000/api/kernels"

    ProxyPass "/" "http://127.0.0.1:3000/"
    ProxyPassReverse "/" "http://127.0.0.1:3000/"

关键是我用最后两行将 websocket 流量转换为 http 流量。所以当然没用。

添加的中间线模式匹配 websocket 请求并将其传递给 ws: 协议。

此外,行的顺序也很重要,因为 ProxyPass "/" 匹配所有内容,而 Apache 会遍历列表,直到找到匹配的内容。所以“匹配一切”这一行必须放在最后。

于 2016-10-05T05:35:21.237 回答