Having difficulty deploying a streamlit app on AWS using ECR + ECS. Not sure if networking problem or something else, someone please help.

0

I have got a streamlit app, I dockerize it and deploy it locally to test and it works perfectly fine. The dockerfile is as such:

https://imgur.com/Zp71oGN - dockerfile

I made my cluster on ECS on a brand new VPC that I made with two PUBLIC available subnets, which both go through a route table and have internet gateway access.

For the ECS task definition, these are my settings:

https://imgur.com/xH05CoG - initial settings for ECS task def.

https://imgur.com/bMzt8kH - more settings for ECS task def. Here are some of the port mappings

After making the task definition and running it on my cluster, I can look at the logs and I see this:

https://imgur.com/PXXRYP2 - This shows that it is indeed running on 0:0:0:0:PORT

It provisions properly and is running smoothly, and here are my inbound outbound rule settings from the EC2:

https://imgur.com/FEY3shK - inbound outbound rules from EC2


I seriously don't understand what the issue may be, I even nuked the entire VPC and made a brand new fresh VPC with two publicly available subnets with internet access and hosted my ECS cluster on that which deploys the instance on it. I edited my dockerfile to ensure that I expose the port and open it up, I made sure I have the correct port mappings in the task definition, I have also opened up like every single inbound rule at this point I don't even know what the issue may be, have you encountered anything like this? This is the error I get from chrome when I try to connect, https://imgur.com/QBBWovy

when I change the port to something random (like one that I DID NOT expose) it takes a LONGGG time to load, the loading icon just keeps spinning, but if I use the correct port, I instantly get the previous error in the imgur. Lastly, yes, I tried switching the port too, I initially tried 8501, the default streamlit port and then I am now trying 8000 and still no luck.

1 Answer
-1

From the information you've provided, it seems like you've set up the ECS task definition and the associated infrastructure correctly, including the Dockerfile configuration and networking settings. However, the issue might be related to how the Streamlit app is handling incoming requests or how the ECS service is exposing the port.

The error message you're receiving from Chrome ("ERR_EMPTY_RESPONSE") indicates that the connection was established, but the server did not send a response. Here are a few steps to troubleshoot:

  1. Health Check Configuration: Ensure that your ECS service's health check configuration in the task definition is correctly configured to check the health of your Streamlit app. This ensures ECS recognizes the app as healthy.

  2. Security Groups and Network ACLs: Double-check the security groups associated with your ECS service, ensuring they allow inbound traffic on the specified port (8000 or whichever port you're using). Also, verify that the network ACLs for your subnets are properly configured to allow the necessary traffic.

  3. Logging and Debugging: Check the logs of your Streamlit application within the ECS container to see if there are any errors or issues reported by the app itself. You can use the ECS console or AWS CLI to retrieve the container logs (aws ecs describe-tasks and aws logs commands).

  4. Port Configuration in Streamlit App: Ensure that your Streamlit app inside the Docker container is correctly configured to listen on the correct port (8000 in this case). Check the Streamlit script or configuration files to verify the port it's bound to.

  5. Test Locally: Run the Docker container with the Streamlit app locally and ensure it functions correctly on port 8000. This helps isolate whether the issue is specific to the AWS ECS setup.

  6. Security Groups and Load Balancers: If you're using a load balancer, confirm its configuration and associated security groups to ensure traffic is correctly routed to your ECS instances.

Remember, debugging networking issues can be complex. Sometimes, the issue might not be directly related to AWS configurations but rather with how the application is handling requests or the environment variables within the container.

If you exhaust these steps and are still facing issues, consider reaching out to AWS support for further assistance. Also, community forums like the AWS Developer Forums or Stack Overflow might provide insights from others who have encountered similar problems.

Ensure sensitive information (like IP addresses, security group names, or any access keys) is not shared publicly for security reasons.

answered 5 months ago
  • This seems like some automated answer, it doesn't help.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions