Remote server deployment issue: WebSocketClosedError

Hi,

I’m running my panel application locally without any problem. I then deployed it on a remote server with a preconfigured environment. It start up fine, loading the basic panel view. Then when I click a button I can see that it starts to work (some immediate changes occur), but it later freezes and doesn’t display further changes. I’m seeing these repeating errors:

Future exception was never retrieved
future: <Future finished exception=WebSocketClosedError()>
Traceback (most recent call last):
    File "/opt/anaconda/envs/env-panel2/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
    File "/opt/anaconda/envs/env-panel2/lib/python3.6/site-packages/bokeh/server/views/ws.py", line 269, in write_message
        yield super(WSHandler, self).write_message(message, binary)
    File "/opt/anaconda/envs/env-panel2/lib/python3.6/site-packages/tornado/websocket.py", line 339, in write_message
        raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError

The deployment command I used is:
panel serve Notebook_Name.ipynb --port 5100 --allow-websocket origin=fake.internal.address.com:XXXX

Any idea how I can make the server “wait enough time” for everything to compute and display without these web socket errors?

Thanks in advance,
Noa

I managed to answer my own question using https://docs.bokeh.org/en/latest/docs/reference/command/subcommands/serve.html

For future reference:
You can set (in milliseconds) the following 2 parameters:
–unused-session-lifetime 60000 [to define the length of a session before Bokeh deems it unused]
–keep-alive 10000 [how often bokeh pings the app to keep it alive]

I’m still getting a freeze after a few minutes despite the keep alive :woman_shrugging: , but it’s getting usable now.

Glad you figured this out and thanks for posting the answer. The issue with keep-alive is worth filing with bokeh because that should definitely work.