Skip to content

Make websocket_max_message_size configurable in notebooks #8583

@nasedil

Description

@nasedil

When bokeh server is embedded in a notebook (like here https://github.com/bokeh/bokeh/blob/master/examples/howto/server_embed/notebook_embed.ipynb) there are connection errors when plots are large, like in #7374 (and smaller plots work just fine). I see from the docs I can use --websocket-max-message-size argument or websocket_max_message_size kwarg with a large enough value for a standalone bokeh server.

However, it is not currently possible to pass that argument to the Server class from notebook when using bokeh.io.show(app, notebook_url):

server = Server({"/": app}, io_loop=loop, port=port, allow_websocket_origin=[origin])

The solution would be to pass something like server_kwargs to show() so that they go through to the Server.__init__.

An example notebook to test the functionality can be constructed from the following code:

import numpy as np

from bokeh.plotting import figure
from bokeh.io import show, output_notebook
from bokeh.palettes import Inferno

output_notebook()

def modify_doc(doc):
    size = 3000
    a = np.broadcast_to((np.arange(size, dtype=np.float64))[np.newaxis, :], (size, size))

    plot = figure(x_range=(0, 100), y_range=(0, 100))
    plot.image(
        image=[a], x=[0], y=[0], dw=[100], dh=[100],
        palette=Inferno[256]
    )
    
    doc.add_root(plot)

show(modify_doc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions