☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Accessing upload file in <input> inside a div model

Community Supportcustomjsbokeh
Matthbt
Matthbt

Hello,

I am sending large files to the server with FileInput model so the websocket is automatically closed. I tried to inscrease the websocket max message size but it is not working. Then I am trying something new.

I created the following div model:
div= Div(
text=‘’,
)
and a submit button: submit = Button(
label = “Submit file”
)

Is there a way to access the file upload with via a CustomJS on the submit button or something ?

Thanks in advance.

⌁   Link to post
Icoti
Icoti

How big is your file?

I had the same problem with a file of about 30 MB, using the option --websocket-max-message-size solved the problem.

For example, I started my app with following command:

bokeh serve --show file_name.py --websocket-max-message-size 1000000000

If this doesn’t help, please provide a minimal reproducible example for us to investigate it.

⌁   Link to post
Matthbt
Matthbt

The file is 9Mo so not so large but still enough to make the websocket closed.
To add context to my problem, the bokeh serve is deployed on a openshift v4 container.
Regarding the --websocket-max-message-size I tried but it is sill not working…

⌁   Link to post
Icoti
Icoti

Well this is strange because the standard value is already 20 MB.
See help text if you write bokeh serve --help:

--websocket-max-message-size BYTES
         Set the Tornado websocket_max_message_size value (default: 20MB)

And my experience is that 9 Mo (≈ 9 MB) should work.
Your problem may have something to do with OpenShift.

To test if your problem is due to Bokeh, try to run following code directly (not on OpenShift):

from bokeh.io import curdoc
from bokeh.models import FileInput

file_input = FileInput(width=600)
def file_callback(attr, old, new):
    print(f"-> New file loaded, beginning with: {new[:20]}...")

file_input.on_change('value', file_callback)

curdoc().add_root(file_input)

Run with: bokeh serve --show file_name.py
Then try to upload a file. You will see in the logs if it works or not.

Increasing the file size, you will see that somewhere between 10 and 20 MB this doesn’t work anymore, the message WebSocket connection closed: code=None, reason=None is shown.
Then, using the option “–websocket-max-message-size 1000000000”, files of more than 100 MB should be loadable.

Also, I think I didn’t right understand how you really try to catch the file in your code.
You say in the text that you use FileInput model but in your code I only see a Div and a Button but no FileInput.
For further help, please provide a minimal reproducible example.

⌁   Link to post
Matthbt
Matthbt

Thanks for the answer.

Loading a file via a FileInput model works in local (in my computer) but does not when I deploy the app on OpenShift. That is why I tried another solution, to create a html input within a div and upload the file with it. But I got the same problem, it works in local and while deployed in Openshift, the websocket is closed. And I tried to use the option “–websocket-max-message-size 1000000000”

Your example is the same code that I created, it works in local but not in a Openshift container.

In the end, it looks like the –websocket-max-message-size param is not taken into account, even if the logs indicates it

⌁   Link to post
Bryan
Bryan

Literally the only Bokeh does with this value is pass it on to the corresponding underlying Tornado API:

So, while it’s not impossible that there is a bug in Tornado, considering things works locally, it seems much more likely to me that this is a limitation or configuration issue with Openshift (obviously Bokeh has no control over that). I’d suggest you try to find a support forum for Openshift that might be able to shed more light on things from the Openshift side of things (I have zero experience with it, and cannot offer any guidance about it).

⌁   Link to post
Matthbt
Matthbt

To summarize, I had problem to upload a large file with FileInput model in my app deployed in Openshift. It was working fine in local so I searched in the configuration parameters of Openshift and find the one responsible for the max websocket size. Increasing it worked.

⌁   Link to post

End of archived discussion · Replies are disabled