Change to bokeh serve in version 3

Migrating from bokeh 2.4.3 to bokeh 3.1.1 and noticed the browser does not show anything in bokeh 3.1.1 with a server pattern that worked with bokeh 2.4.3.

bokeh application minimal example (bkh.py)

from bokeh.io import curdoc
from bokeh.plotting import figure

fig = figure(title='Line plot!', width=800, height=300)
fig.line(x=[1, 2, 3], y=[1, 4, 9])
curdoc().add_root(fig)

Server deployment with bokeh 2.4.3

bokeh serve bkh.py --port 5007 --allow-websocket-origin 10.144.240.35:5007

Server deployment with bokeh 3.1.1

bokeh serve bkh.py --port 5008 --allow-websocket-origin 10.144.240.35:5008

Browser with bokeh 2.4.3

Browser with bokeh 3.1.1 (the figure does not show up at all)

The IP address in the browser screenshots is a cloud server (AWS).

Are there any errors or messages reported in either the system console where bokeh serve is run, or in the browser JavaScript console for the page that loaded the URL?

Here is the system console just after loading the bokeh 2.4.3 app in Chrome -

2023-06-12 23:02:04,393 Starting Bokeh server version 2.4.3 (running on Tornado 6.3.2)
2023-06-12 23:02:04,394 User authentication hooks NOT provided (default user enabled)
2023-06-12 23:02:04,396 Bokeh app running at: http://localhost:5007/bkh
2023-06-12 23:02:04,396 Starting Bokeh server with process id: 29183
2023-06-12 23:02:11,424 WebSocket connection opened
2023-06-12 23:02:11,425 ServerConnection created

And browser console for same -

Here is the system console for bokeh 3.1.1 (did not open the WebSocket connection)

2023-06-12 23:03:28,810 Starting Bokeh server version 3.1.1 (running on Tornado 6.3.2)
2023-06-12 23:03:28,940 User authentication hooks NOT provided (default user enabled)
2023-06-12 23:03:28,942 Bokeh app running at: http://localhost:5008/bkh
2023-06-12 23:03:28,942 Starting Bokeh server with process id: 29222

and here is the browser console

The root cause seems to be that bokeh 3.1.1 cannot access static/js/bokeh.min.js whereas bokeh 2.4.3 can access that resource.

This is the browser page source with bokeh 2.4.3

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Bokeh Application</title>
    <script type="text/javascript" src="static/js/bokeh.min.js?v=3c61e952

and the link to bokeh.min.js contains the IP of the cloud server - http://10.144.240.35:5007/static/js/bokeh.min.js?v=3c6...

However with bokeh 3.1.1 the link to bokeh.min.js in the page source is an absolute path that can’t be reached -

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Bokeh Application</title>
    <style>
      html, body {
        box-sizing: border-box;
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
    <script type="text/javascript" src="http://localhost:5007/static/js/bokeh.min.js?v=c8d

For this reason bokeh 3.1.1 will properly run the minimal example on a laptop where the absolute path above to bokeh.min.js is valid. However the case of using a cloud server (my case) will not work.

Seems like it might be this

You’d have to open up the browser network dev tools to confirm that the load URL is “localhost”

The current workaround, assuming you are not inside an airgapped environment, is to switch to using CDN resources as described in the issue. In fact, for “production” I would probably just always recommend using CDN resources as the best practice.

Thank you and correct, that was the issue.
I confirmed no issue in bokeh 3.1.0 as described in the bug report.
The solution to my specific issue then is to use bokeh 3.1.1 but run the application as -

BOKEH_RESOURCES=cdn bokeh serve bkh.py --port 5007 --allow-websocket-origin 10.144.240.35:5007
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.