Jupyter仪表板服务器 - 堆栈或流量不可用的一部分

时间:2016-10-03 15:11:15

标签: jupyter jupyter-irkernel

我无法理解jupyter仪表板服务器的哪个部分无法正常工作。 似乎仪表板服务器正在运行,内核网关正在运行并且内核已启动,但由于某种原因,启动后内核的websocket流量获得404作为响应。

我尝试在内核网关上执行curl请求,但curl不支持'ws'协议。

如何进一步调试?以下所有细节。

我有一个使用此Apache配置的VM(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   

enter image description here

我也尝试在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'

1 个答案:

答案 0 :(得分: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:protocol。

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