Streamlit version 1.23.1: WebSocket Timeout Issue


I am trying to read a 70 MB csv.gz file from AWS S3 in a pandas data frame. The streamlit app throws WebSocket error as shown below.

Code snippet:

# file_name:
import streamlit as st
import boto3
import pandas as pd


st.write("# Dashboard! 👋")

bucket = "test-s3-bucke"
key = "/path/to/file/sample-data-70-mb.csv.gz"
s3 = boto3.resource('s3')
obj = s3.Object(bucket, key)

# download the file from s3
# read into dataframe
df = pd.read_csv('test.csv.gz', compression='gzip')

Error snippet:

Task exception was never retrieved
future: <Task finished name='Task-2436' coro=<WebSocketProtocol13.write_message.<locals>.wrapper() done, defined at /opt/conda/lib/python3.9/site-packages/tornado/> exception=WebSocketClosedError()>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.9/site-packages/tornado/", line 1087, 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 "/opt/conda/lib/python3.9/site-packages/tornado/", line 1089, in wrapper
    raise WebSocketClosedError()

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Steps to reproduce:

streamlit run

Expected behavior:

It should show a data frame on the dashboard

Actual behavior:

Error as shown above

Debug info

  • Streamlit version: 1.23.1
  • Python version: python 3.9.15
  • Using Conda? PipEnv? PyEnv? Pex? conda
  • OS version: “Amazon Linux 2”
  • Browser version: Version 114.0.5735.134 (Official Build) (64-bit)

Requirements file

1 Like

Hi @gallanik,

Thanks for posting and welcome to Streamlit Community Forum! :raised_hands:t5:

From the error snippet, it seems the WebSocket connection was closed at some point in the process. My guess is that the dataset might be too big to be sent in a single message or maybe it’s consuming too much memory hence the connection being terminated.

To troubleshoot this, try:

  • loading a small portion of the dataset e.g.: df = pd.read_csv('test.csv.gz', compression='gzip', nrows=100) to load only the first 100 rows
  • You can also try increasing the WebSocket message size limit to 500MB by adding the following to ~/.streamlit/config.toml:
    maxMessageSize = 500

Also, let us know if you start running into high resource utilization once the app starts reading the dataset if you deployed the app on Streamlit Community Cloud.

Happy Streamlit-ing! :balloon:

Hi, I’m facing a websocket issue with all the streamlit pages showing “Please wait” for around a minute or more before rendering the components. Sometimes the page loads up fast but most of the times it takes a long time before showing the components.

Now, this happens only when I hit the server through the AWS ALB HTTPS URL and that too, not all the time (so perhaps not security group issue). Hitting the ec2 instance server directly works perfectly without any timeouts for websockets or the /_stcore/stream endpoints. The console shows websocket time out for “wss://domain/_stcore/stream” multiple times and then finally after a while it becomes 101 status and connection upgrade for that endpoint and displays the page.

I’m not using Nginx, I’m using AWS ALB for SSL termination. I have tried setting the CORS, webSocketCompression and other flags to false but nothing worked. Tried with different browsers, still no luck. Streamlit 1.24.0 and python 3.9 (tried 3.10 but still no luck). If someone could help on this, that would be really great!

I have the same issue with Please wait page. I am running in Azure environment.

1 Like

Did you manage to fix this issue? I still get the web socket time out issue intermittently while accessing the app via AWS load balancer configured HTTPS url.

It turned out that my company uses Azure Front Door as Firewall/CDN and it does not support websockets. So I have to use Azure Gateway instead Azure Front Door because it has native WebSocket support.

  1. I would recommend checking that AWS load balancer configured for websockets correctly. For example, see:

    Listeners for your Application Load Balancers - Elastic Load Balancing (

  2. Also, I would recommend checking what other parts of AWS infrastructure you have and if they support WebSocket connections and if that WebSocket connection is open.

  3. Next I would check on application level if you use reverse proxy or any other staff on top of your streamlit app

  4. Finally sometimes settings config.toml could help to resolve WebSocket problem
    headless = true
    port = 8080

If you do not lock with AWS you can try to use e.g. Google Cloud Load Balancing or Nginx/Traefik. Also If you believe that AWS load balancer is the problem you can create support ticket with AWS. If you are enterprise client, they should help to setup it correctly.

1 Like


Thank you so much for sharing this in detail! I will have a look at all of these and give it a go. The thing which confuses me is that, the issue seems to be intermittent. Sometimes the “please wait” would be for the initial loading of the page but sometimes, the page would load instantly and then after a minute or so, it would go back to “please wait” on loading of another page within my multi page app.

The web socket upgrade works, but not all the time. If it was a support issue for web sockets or firewall, I thought it wouldn’t have worked even once. Did your application have this issue intermittently or did it not load even once after the “please wait”?

I tried the config.toml steps but no luck with that. I will check with the IT team regarding any restrictions w.r.t web sockets and also, with AWS support to see if they can figure out something since it’s only happening when accessed through ALB. Once again, thanks for the reply.

Sure, you are welcome!

My app did not load even once after the “please wait” so I am not sure why you sometimes get “please wait” after a minute and sometimes right away. Do you run several instances of an app? Can you try to scale down to one instance and check if app work or not (or work for one minute)?

SInce my app is a multi-page application, there are anchor tags for navigating to those new pages. So, I believe the websocket connection upgrade request is sent each time when the new page links are clicked. However, I still have no idea why it would load up instantly some times and takes a minute or two at other times before loading, even for the same page.

Everything works fine with hitting the ec2 instance directly and locally. The issue is only when application is behind a reverse proxy - AWS ALB in my case. So, I guess I will have to seek help from AWS support to see if they can figure something out.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.