Streamlit app WebSocket connection failed with ALB + ECS deployment

Hello,

I’m trying to deploy Streamlit app on AWS ECS behind an ALB is experiencing an issue, the page seems keep loading as blank page when accessed from the network, the websocket connection consistently fails with the WSS error: WebSocket connection to `ws://{ALB_DNS_NAME}/_stcore/stream` failed: The network connection was lost. Client Error: WebSocket onerror. The request to host-config and health check both returned 200 status code, and the request to we://_stcore/stream return 101 code switching protocols.

  • Troubleshooting steps already taken include:

    • Configuring Streamlit with .streamlit/config.toml to set server.address = "0.0.0.0".

    • Enabling session stickiness on the target group associated with the Streamlit ECS service.

    • Setting the ALB idle timeout to a long duration (1 hour).

    • Verifying ECS task health checks, indicating the HTTP connection is working.

Any solutions?