Bokeh script tag from server_document does not work

I am trying the example code for embedding a bokeh server app in html using the server_document() function.

I am getting a websocket connection error

WebSocket connection to 'ws://demo.bokeh.org/sliders/ws' failed:

The html code is:

<html>
    <body>
        <script
            src="https://demo.bokeh.org/sliders/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/sliders&bokeh-absolute-url=https://demo.bokeh.org/sliders"
            id="1000">
        </script>
    </body>
</html>

any ideas?

Generally speaking, anyone who deploys a Bokeh server app will want to exert control over who and where the app can be emedded, and not e.g. allow anyone in the world to directly embed their app without their permission. The demo site is not configured to allow connections like this, except from requests that have demo.bokeh.org as their ORIGIN (which will not be the case for where ever your page is hosted).

You will need to try things out with a Bokeh server that you run yourself, with --allow-websocket-origin or BOKEH_ALLOW_WS_ORIGIN configured to allow connections from your embedding origin (or "*" to open things up to any origin).

Thank you! I tried my own server app with --allow-websocket-origin and I was able to successfully embed the app in an html file.

1 Like

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