Tornado/websocket.py error on 0.71.0 and 0.72

I encountered a local error on tornado / websocket.py. This occurs after about a minute the app is processing. Unfortunately the problem makes the app totally unusable. How can I solve? I’ve got 0.71.0 version. Thanks

From the consolle:

2020-12-12 18:25:48.790 Task exception was never retrieved
future: <Task finished name=‘Task-413’ coro=<WebSocketProtocol13.write_message..wrapper() done, defined at /home/fabio/.local/lib/python3.8/site-packages/tornado/websocket.py:1102> exception=WebSocketClosedError()>
Traceback (most recent call last):
File “/home/fabio/.local/lib/python3.8/site-packages/tornado/websocket.py”, line 1104, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/fabio/.local/lib/python3.8/site-packages/tornado/websocket.py”, line 1106, in wrapper
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
2020-12-12 18:25:48.792 Task exception was never retrieved
future: <Task finished name=‘Task-414’ coro=<WebSocketProtocol13.write_message..wrapper() done, defined at /home/fabio/.local/lib/python3.8/site-packages/tornado/websocket.py:1102> exception=WebSocketClosedError()>
Traceback (most recent call last):
File “/home/fabio/.local/lib/python3.8/site-packages/tornado/websocket.py”, line 1104, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

etc…etc…

1 Like

Hello, is there any update on this? I am facing the same issue with 0.74.1 version. Any work around? Thank you

I am also facing thesame issue. In My case:

The App is Meant to run some backend data manipulation and produce an xlsx file.

The Apps works great if the xlsx file is small. Anything above 15MB I get this error:
ERROR: Task exception was never retrieved
line 1104, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:
future: <Task finished coro=<WebSocketProtocol13.write_message..wrapper() done,

Then the page refreshes, causing me to loose the download file

My streamlit version is 0.68.0

3 Likes

@Fabio_Pasquarella @Jeffery_Ansah Guys did you find any workaround ? I am facing the same error , and this is the first time I have experienced this and there is not much documentation on it

1 Like

Hello @Jeffery_Ansah! I have the same issue with an app that uses a CSV file of around 50 MB. Any advice on how to solve this problem?

@sayalaruano @av_abhishiek : To resolve this, I did the following:

  • I modified the MESSAGE_SIZE_LIMIT variable in the the server_utils.py file (found here: .\venv\Lib\site-packages\streamlit\server\server_util.py). By default this is set to 50MB, I have currently modified mine to 600MB and it works without any issues. This should fix the issue.

  • I also increased the "websocket_ping_timeout": 30, in the TORNADO_SETTINGS dictionary located in the Lib\site-packages\streamlit\server\server.py file from 30 seconds to 200s

Additional Tweaks for efficiency and to prevent my app from timing out was to route all my files to the .\Lib\site-packages\streamlit\static\downloads folder and then render the file directly from there. I find that doing this prevented my app from timing out when downloading large files.

I am not an expert, but this is what has worked for me for the past 16 months.

2 Likes

Just a heads-up that this has been configurable for some time in Streamlit, and with this thread referencing 0.71 and 0.72, everyone should upgrade to get two years of performance improvements.

Best,
Randy