2016-10-03 15 views
0

我無法理解jupyter儀表板服務器的哪個部分無法工作。 似乎儀表板服務器正在工作,內核網關正在工作,內核啓動,但由於某種原因啓動後,內核的websocket流量獲得了404作爲響應。Jupyter儀表板服務器 - 堆棧或流量不工作的一部分

我試過在內核網關上做一個curl請求,但curl不支持'ws'協議。

如何進一步調試?下面的所有細節。

我有一個VM(Debian的傑西)與此Apache配置:

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

想通了。

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會遍歷列表直到找到匹配的內容。所以「匹配所有」線必須是最後一個。