运行 url 上的 jupyter notebook 运行 内联散景应用程序不同于 localhost:8888

Running bokeh application inline in jupyter notebook running on url different than localhost:8888

版本:Python3.6,Bokeh 1.3.4

到目前为止,我无法在 jupyter notebook 中显示内联的 Bokeh 应用程序,它在虚拟机上 运行ning 并通过 ssl 隧道访问。

从文档中我了解到,当 notebook_url 与 localhost:8888 不同时,我必须通过它。我如何访问 VM 的远程笔记本是 localhost:8900。所以我尝试了以下方法:

from bokeh.models.widgets import RangeSlider
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
from bokeh.io import output_notebook, show

output_notebook()


def test(doc):
    
    def testFunc(attr,old,new):
        print(new)
    
    testSlider = RangeSlider(start=0, end=10, value=(0,10), step=1, title="year")
    testSlider.on_change("value",testFunc)
    
    doc.add_root(testSlider)
show(Application(FunctionHandler(test)),notebook_url='localhost:8900')

可以在我的笔记本电脑上使用(url),但不能在 VM 的笔记本电脑上使用。它确实显示 Bokeh 已正确加载,并且当我 运行 上面的命令时,任何地方都不会弹出错误。

显示散景小部件在笔记本中可以正常工作。

我错过了什么?

问题如 bigreddot 指出的那样,用于 websocket 连接的附加端口被阻止。为了解决这个问题,我在另一个端口 8903 上打开了另一个 ssl 隧道,并调用了 show 函数:

show(Application(FunctionHandler(test)),notebook_url='localhost:8900',port=8903)