Problem with embedding a Bokeh server in a Notebook

I’m trying to run the example from https://github.com/bokeh/bokeh/blob/master/examples/howto/server_embed/notebook_embed.ipynb and have problem running it on a custom domain / self-hosted jupyterhub server.

Running that example using localhost jupyterlab works fine.

On the self-hosted jupyterhub server if I run show(notebook_url=“https://mydomain.dev”) I get error 404 in my network log for URL similar to the following:

https://mydomain.dev/user/myuser/43568/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/https:43568&bokeh-absolute-url=https:43568&resources=none

If I run show(notebook_url=“https://mydomain.dev:443”) then URL similar to the following does not loads because browser is unable to connect (apparently because it tries to connect using port 36520):

https://mydomain.dev:36520/autoload.js?bokeh-autoload-element=1006&bokeh-absolute-url=https://mydomain.dev:36520&resources=none

The corresponding script URL for the localhost juptyer instance which loads fine is:

http://localhost:37595/autoload.js?bokeh-autoload-element=1400&bokeh-absolute-url=http://localhost:37595&resources=none

Here’s the copy of the code from the example:

import yaml

from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
from bokeh.themes import Theme
from bokeh.io import show, output_notebook

from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature

output_notebook()

def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25),
                  y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    doc.theme = Theme(json=yaml.load("""
        attrs:
            Figure:
                background_fill_color: "#DDDDDD"
                outline_line_color: white
                toolbar_location: above
                height: 500
                width: 800
            Grid:
                grid_line_dash: [6, 4]
                grid_line_color: white
    """))
#show(modify_doc, notebook_url="https://mydomain.dev") # not working
#show(modify_doc, notebook_url="https://mydomain.dev:443") # not working either
show(modify_doc) # this one is working properly

``


What might be wrong here? Maybe something else should be used for the notebook_url argument?

``

this sounds more like a problem with binding to interfaces than a problem with bokeh per se.

“localhost” is understood by the OS to mean 127.0.0.1 while “mydomain.dev” will be some other address. and the Bokeh server is probably listening on 127.0.0.1. so you need to find some way of binding the bokeh server to the address you want. probably you need to manually start the server yourself. see Bokeh server — Bokeh 3.3.2 Documentation

···

On Friday, 11 January 2019 12:38:04 UTC-3, [email protected] wrote:

I’m trying to run the example from https://github.com/bokeh/bokeh/blob/master/examples/howto/server_embed/notebook_embed.ipynb and have problem running it on a custom domain / self-hosted jupyterhub server.

Running that example using localhost jupyterlab works fine.

On the self-hosted jupyterhub server if I run show(notebook_url=“https://mydomain.dev”) I get error 404 in my network log for URL similar to the following:

https://mydomain.dev/user/myuser/43568/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/https:43568&bokeh-absolute-url=https:43568&resources=none

If I run show(notebook_url=“https://mydomain.dev:443”) then URL similar to the following does not loads because browser is unable to connect (apparently because it tries to connect using port 36520):

https://mydomain.dev:36520/autoload.js?bokeh-autoload-element=1006&bokeh-absolute-url=https://mydomain.dev:36520&resources=none

The corresponding script URL for the localhost juptyer instance which loads fine is:

http://localhost:37595/autoload.js?bokeh-autoload-element=1400&bokeh-absolute-url=http://localhost:37595&resources=none

Here’s the copy of the code from the example:

import yaml

from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
from bokeh.themes import Theme
from bokeh.io import show, output_notebook

from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature

output_notebook()


def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25),
                  y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    doc.theme = Theme(json=yaml.load("""
        attrs:
            Figure:
                background_fill_color: "#DDDDDD"
                outline_line_color: white
                toolbar_location: above
                height: 500
                width: 800
            Grid:
                grid_line_dash: [6, 4]
                grid_line_color: white
    """))
#show(modify_doc, notebook_url="[https://mydomain](https://mydomain).dev") # not working
#show(modify_doc, notebook_url="[https://mydomain.dev:443](https://mydomain.dev:443)") # not working either
show(modify_doc) # this one is working properly

``


What might be wrong here? Maybe something else should be used for the notebook_url argument?

``

Maybe relevant (not entirely sure) but notebook_url can also be a callable, if you need finer control in order to deal with some situations, see:

  bokeh server support for running in JupyterHub. (#7685) by cbanek · Pull Request #7686 · bokeh/bokeh · GitHub

For history/details.

Thanks,

Bryan

···

On Jan 12, 2019, at 10:09, [email protected] wrote:

this sounds more like a problem with binding to interfaces than a problem with bokeh per se.

"localhost" is understood by the OS to mean 127.0.0.1 while "mydomain.dev" will be some other address. and the Bokeh server is probably listening on 127.0.0.1. so you need to find some way of binding the bokeh server to the address you want. probably you need to manually start the server yourself. see Bokeh server — Bokeh 3.3.2 Documentation

On Friday, 11 January 2019 12:38:04 UTC-3, eugene.p...@gmail.com wrote:
I'm trying to run the example from https://github.com/bokeh/bokeh/blob/master/examples/howto/server_embed/notebook_embed.ipynb and have problem running it on a custom domain / self-hosted jupyterhub server.

Running that example using localhost jupyterlab works fine.

On the self-hosted jupyterhub server if I run show(notebook_url="https://mydomain.dev") I get error 404 in my network log for URL similar to the following:
https://mydomain.dev/user/myuser/43568/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/https:43568&bokeh-absolute-url=https:43568&resources=none

If I run show(notebook_url="https://mydomain.dev:443") then URL similar to the following does not loads because browser is unable to connect (apparently because it tries to connect using port 36520):
https://mydomain.dev:36520/autoload.js?bokeh-autoload-element=1006&bokeh-absolute-url=https://mydomain.dev:36520&resources=none

The corresponding script URL for the localhost juptyer instance which loads fine is:
http://localhost:37595/autoload.js?bokeh-autoload-element=1400&bokeh-absolute-url=http://localhost:37595&resources=none

Here's the copy of the code from the example:
import yaml

from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
from bokeh.themes import Theme
from bokeh.io import show, output_notebook

from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature

output_notebook()

def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25),
                  y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    doc.theme = Theme(json=yaml.load("""
        attrs:
            Figure:
                background_fill_color: "#DDDDDD"
                outline_line_color: white
                toolbar_location: above
                height: 500
                width: 800
            Grid:
                grid_line_dash: [6, 4]
                grid_line_color: white
    """))

show(modify_doc) # this one is working properly
#show(modify_doc, notebook_url="https://mydomain.dev") # not working
#show(modify_doc, notebook_url="https://mydomain.dev:443") # not working either

What might be wrong here? Maybe something else should be used for the notebook_url argument?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5710cde4-53e8-4e2e-9ab0-4d2a99c9ca5b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thanks Bryan,

that pull request page has lead to the docs page https://bokeh.pydata.org/en/latest/docs/user_guide/notebook.html#jupyterhub which has the solution I needed. Now it works.

···

суббота, 12 января 2019 г., 22:20:35 UTC+3 пользователь Bryan Van de ven написал:

Maybe relevant (not entirely sure) but notebook_url can also be a callable, if you need finer control in order to deal with some situations, see:

    [https://github.com/bokeh/bokeh/pull/7686](https://github.com/bokeh/bokeh/pull/7686)

For history/details.

Thanks,

Bryan

On Jan 12, 2019, at 10:09, [email protected] wrote:

this sounds more like a problem with binding to interfaces than a problem with bokeh per se.

“localhost” is understood by the OS to mean 127.0.0.1 while “mydomain.dev” will be some other address. and the Bokeh server is probably listening on 127.0.0.1. so you need to find some way of binding the bokeh server to the address you want. probably you need to manually start the server yourself. see https://bokeh.pydata.org/en/latest/docs/user_guide/server.html

On Friday, 11 January 2019 12:38:04 UTC-3, [email protected] wrote:

I’m trying to run the example from https://github.com/bokeh/bokeh/blob/master/examples/howto/server_embed/notebook_embed.ipynb and have problem running it on a custom domain / self-hosted jupyterhub server.

Running that example using localhost jupyterlab works fine.

On the self-hosted jupyterhub server if I run show(notebook_url=“https://mydomain.dev”) I get error 404 in my network log for URL similar to the following:

https://mydomain.dev/user/myuser/43568/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/https:43568&bokeh-absolute-url=https:43568&resources=none

If I run show(notebook_url=“https://mydomain.dev:443”) then URL similar to the following does not loads because browser is unable to connect (apparently because it tries to connect using port 36520):

https://mydomain.dev:36520/autoload.js?bokeh-autoload-element=1006&bokeh-absolute-url=https://mydomain.dev:36520&resources=none

The corresponding script URL for the localhost juptyer instance which loads fine is:

http://localhost:37595/autoload.js?bokeh-autoload-element=1400&bokeh-absolute-url=http://localhost:37595&resources=none

Here’s the copy of the code from the example:

import yaml

from bokeh.layouts import column

from bokeh.models import ColumnDataSource, Slider

from bokeh.plotting import figure

from bokeh.themes import Theme

from bokeh.io import show, output_notebook

from bokeh.sampledata.sea_surface_temperature import sea_surface_temperature

output_notebook()

def modify_doc(doc):

df = sea_surface_temperature.copy()
source = ColumnDataSource(data=df)
plot = figure(x_axis_type='datetime', y_range=(0, 25),
              y_axis_label='Temperature (Celsius)',
              title="Sea Surface Temperature at 43.18, -70.43")
plot.line('time', 'temperature', source=source)
def callback(attr, old, new):
    if new == 0:
        data = df
    else:
        data = df.rolling('{0}D'.format(new)).mean()
    source.data = ColumnDataSource(data=data).data
slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
slider.on_change('value', callback)
doc.add_root(column(slider, plot))
doc.theme = Theme(json=yaml.load("""
    attrs:
        Figure:
            background_fill_color: "#DDDDDD"
            outline_line_color: white
            toolbar_location: above
            height: 500
            width: 800
        Grid:
            grid_line_dash: [6, 4]
            grid_line_color: white
"""))

show(modify_doc) # this one is working properly

#show(modify_doc, notebook_url=“https://mydomain.dev”) # not working

#show(modify_doc, notebook_url=“https://mydomain.dev:443”) # not working either

What might be wrong here? Maybe something else should be used for the notebook_url argument?


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/5710cde4-53e8-4e2e-9ab0-4d2a99c9ca5b%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.