Connection errors when sending large amounts of data to browser via a bokeh server
See original GitHub issueRecently I came across a problem with sending lots of data to a bokeh server, between 20 - 50 MB. The command I used was
bokeh serve data_visualisation --show --args -i path_to_large_file
What would happen is that my plot would render, and then almost instantly a timeout would occur so no communication between the browser and server was possible:
2018-01-05 10:19:58,280 200 GET /data_visualisation (::1) 9227.38ms
2018-01-05 10:19:58,455 101 GET /data_visualisation/ws?bokeh-protocol-version=1.0&bokeh-session-id=jbQmzoBZbYDBDUdi5Ix6QShbAJtAMGPhmKvC1SWjOuwA (::1) 0.87ms
2018-01-05 10:19:58,455 WebSocket connection opened
2018-01-05 10:19:58,456 ServerConnection created
2018-01-05 10:21:28,512 WebSocket connection closed: code=None, reason=None
In the browser console, the following errors where shown:
[bokeh] Lost websocket 0 connection, 1006 () connection.js:221
[bokeh] Websocket connection 0 disconnected, will not attempt to reconnect connection.js:105
The problem was solved by editing tornado.py by changing the rule on line 221
super(BokehTornado, self).__init__(all_patterns)
to
super(BokehTornado, self).__init__(all_patterns, websocket_max_message_size=50 * 1024 * 1024)
By default, the maximum socket message size is 10MiB for the used version of Tornado, and would disconnect for this reason. A more meaningful error message or the possibility to change this value in bokeh would be appreciated.
Software version info
bokeh==0.12.13 Tornado==4.5.2 python==3.6.3 MacOS High Sierra (10.13.2) Any browser (Chrome (63.0.3239.84) / Safari / Firefox)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:17 (11 by maintainers)
Top GitHub Comments
I’m working on a PR for this right now.
@Belloco unfortunately it is not possible to provide a better error message. Those messages originate from the browser, and Tornado respectively, not Bokeh. Bokeh only sees that the connection is closed, it does not get any information about why it was closed.
However, if it is possible to expose
websocket_max_message_size
as a user configurable option that that’s certainly reasonable. However it is not completely trivial, as that option appears to be new to Tornado 4.5 and Bokeh support tornado >=4.4 so there will have to be some kind of version handling. Are you interested in helping work up a PR for this?