Search code examples
pythonjupyter-notebookbokeh

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


version: Python 3.6, Bokeh 1.3.4

So far I am unable to show a Bokeh application inline in a jupyter notebook, which is running on a virtual machine and accessed through a ssl tunnel.

From the docs I understood that I had to pass the notebook_url when it is different to localhost:8888. How I access the VM's remote notebook is localhost:8900. So I tried the following:

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')

Which works on my laptop (with different url) but not on the VM's notebook. It does show Bokeh is properly loaded and no errors pop up anywhere when I run the commands above.

Showing bokeh widgets does work properly in the notebook.

What am I missing?


Solution

  • The issue was what bigreddot pointed out, the additional port for a websocket connection was blocked. To resolve this I opened another ssl tunnel on a different port 8903 and called the show function with:

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