Websocket_max_message_size when starting the server from commandline

I have a bokeh 2.3.0 application that I start from the command line with:

bokeh serve --show myApp.py

I found that theres a maximum file size of files I can use with the file_input widget.
I found that the websocket_max_message_size may be responsible for this..
However I’m not able to get this to work. Is the following way of passing the argument correct or I’m I missing something?

bokeh serve --show myApp.py --args websocket_max_message_size=500000000

My application still quits with: WebSocket connection closed: code=None, reason=None.

Any help is appreciated.

Hi @Crysers,

From the information provided, I believe the problem is the syntax in the invocation of the server. There are two specific problems.

  1. The --args command-line switch is the last option in the bokeh serve call and is used to send arguments to your specific application(s) not the bokeh server mechanism.

This is documented in the bokeh reference document here, excerpting the relevant section.

If you would like to pass command line arguments to Bokeh applications, you can pass the --args option as the LAST option on the command line:

bokeh serve app_script.py myapp.py --args foo bar --baz

Everything that follows --args will be included in sys.argv when the application runs. In this case, when myapp.py executes, the contents of sys.argv will be ['myapp.py', 'foo', 'bar', '--baz'], consistent with standard Python expectations for sys.argv.

Note that if multiple scripts or directories are provided, they all receive the same set of command line arguments (if any) given by --args.

  1. The command-line option to set the websocket max message size uses hyphens rather than dashes in the option name, e.g. --websocket-max-message-size=500000000

SOLUTION: Putting it all together, the syntax for your app should be the following.


bokeh serve --show myApp.py --websocket-max-message-size=500000000

And you should see something like this in the server console, which confirms the max websocket size has been set to something other than a default value.

% bokeh serve --show myApp.py --websocket-max-message-size=500000000 
2021-07-14 10:27:57,190 Starting Bokeh server version 2.3.2 (running on Tornado 6.1)
2021-07-14 10:27:57,191 Torndado websocket_max_message_size set to 500000000 bytes (476.84 MB)
2021-07-14 10:27:57,191 User authentication hooks NOT provided (default user enabled)
2021-07-14 10:27:57,193 Bokeh app running at: http://localhost:5006/myApp
2021-07-14 10:27:57,193 Starting Bokeh server with process id: 6523
2021-07-14 10:27:57,539 WebSocket connection opened
2021-07-14 10:27:57,540 ServerConnection created

Hope this helps / makes sense.