Does AWS App Runner properly support WebSocket connections? - amazon-web-services

My AWS App Runner application is running normally,
12-19-2021 05:28:15 PM [AppRunner] Service status is set to RUNNING.
12-19-2021 05:28:15 PM [AppRunner] Service creation completed successfully.
12-19-2021 05:28:14 PM [AppRunner] Successfully routed incoming traffic to application.
12-19-2021 05:27:48 PM [AppRunner] Health check is successful. Routing traffic to application.
12-19-2021 05:26:39 PM [AppRunner] Performing health check on path '/ping' and port '8081'.
12-19-2021 05:26:29 PM [AppRunner] Provisioning instances and deploying image.
12-19-2021 05:26:18 PM [AppRunner] Successfully pulled image from ECR.
12-19-2021 05:24:17 PM [AppRunner] Service status is set to OPERATION_IN_PROGRESS.
12-19-2021 05:24:16 PM [AppRunner] Service creation started.
It's an express/ws application, and it works just fine in Docker locally. I am able to reach the myapplication.com/ WebSocket endpoint when it's running locally. However, I am seemingly unable to reach the WebSocket domain when the app is running on AWS App Runner. The application runs at port 8081 internally, but of course App Runner will port that over to port 80/443 to the outside.
I can confirm that the application is running at-least partially in App Runner, since I can reach the myapplication.com/ping endpoint.
I have tried manually with JavaScript in the console to connect to the WebSocket endpoint with every combination of ws://myapplication.com/, wss://myapplication.com/, wss://myapplication.com:8081/, ws://myapplication.com:8081/ and nothing has worked.
My question is - Does App Runner even support WebSockets? I read this on the documentation of App Runner:
Stateless apps – App Runner doesn't guarantee state persistence beyond the duration of processing a single incoming web request.
This, of course, means that having a long term WebSocket client running on AWS App Runner isn't a great idea, but does it also mean that WebSockets are impossible?

Unfortunately, AWS App Runner doesn't support WebSockets as well as sticky sessions.

Related

Can't update AWS App Runner after creation

The app runner is successfully created and works fine, but any attempt to change the configuration gets an error. It seems that the healthcheck does not work, although after creation everything works fine.
[AppRunner] Service status is set to RUNNING.
[AppRunner] Service update failed. For details, see service logs.
[AppRunner] Performing health check on path '/healthz' and port '8080'.
[AppRunner] Provisioning instances and deploying image.
[AppRunner] Service status is set to OPERATION_IN_PROGRESS.
[AppRunner] Service update started.
[AppRunner] Service status is set to RUNNING.
[AppRunner] Service creation completed successfully.
[AppRunner] Successfully routed incoming traffic to application.
[AppRunner] Health check is successful. Routing traffic to application.
[AppRunner] Performing health check on path '/healthz' and port '8080'.
[AppRunner] Provisioning instances and deploying image.
[AppRunner] Successfully pulled image from ECR.
[AppRunner] Service status is set to OPERATION_IN_PROGRESS.
[AppRunner] Service creation started.
This happens with any change. For example, here I just changed the healthcheck interval from the default 10 seconds to the maximum 20.
At the same time, it is impossible to find any logs explaining what went wrong. Cloudwatch just duplicates the message Service update failed. For details, see service logs.
If it matters, I'm running the application inside a VPC, with NAT configured. There is also a private db instance with access only from the VPC. Healthcheck /healthz checks access to the internet and to the database, there are no problems with this.
Any ideas what I'm doing wrong or where I can find useful logs would be helpful.

How to remove web server in spring boot application and keep deploying into ecs with health check

I have a spring boot service that send and receive messages only from a kafka topic,
I want to remove the web server (tomcat) since there is no need for it.
The problem is the service is currently deployed on ECS and the end point /actuator/health is used to check the health of the service, which means if I remove the web server the deployment in the pipeline won't be successful since the health checks will fail,
I tried making the ALB internal but the Kafka service is not in the same VPC and the service couldn’t connect
Is there any solutions to isolate the service ?

AWS App Runner "Create Failed" on health check

I'm creating my first app on AWS App Runner. I have a simple nginx Docker image that works locally by serving html on localhost:8080.
When I try to deploy it, the result is "Create Failed". Upon digging into the CloudWatch logs, I see that the health check failed. The health check is configured to ping the root of the service "/" at port 8080.
I was able to resolve this by deleting my App Runner app (this is currently the only way to change the configuration-- see this issue), then creating a new one and specifying the health check to ping port 80.
Are you getting this error:
10-21-2021 02:13:32 PM [AppRunner] Health check on port '80' failed. Service is rolling back. Check your configured port number. For more information, read the application logs.
10-21-2021 02:07:40 PM [AppRunner] Performing health check on port '80'.
10-21-2021 02:07:30 PM [AppRunner] Provisioning instances and deploying image.
10-21-2021 02:07:20 PM [AppRunner] Successfully pulled image from ECR.
10-21-2021 02:04:58 PM [AppRunner] Service status is set to OPERATION_IN_PROGRESS.
10-21-2021 02:04:57 PM [AppRunner] Service creation started.
If you are building on an M1 mac by chance? If so that's probably the reason. The image that's being built is of the ARM architecture, and App Runner or Fargate is an x86 runtime.
Aws is working on fixing this issue here: #1949
In the meantime, there's a workaround, you can prefix copilot commands with the DOCKER_DEFAULT_PLATFORM=linux/amd64
For example:
DOCKER_DEFAULT_PLATFORM=linux/amd64 copilot deploy
So basically when you build your docker image just use:
You can use buildx (mobi) which suipport cli for platform.
docker build --platform linux/amd64 -t your-docker-image-name .
Hope that helps, and sorry for the trouble 🙏

How to deploy frontend and backend ECS services?

I am new to ECS. I have an Apollo React web app client and an Apollo Express server API. I have deployed React client (:80) successfully via ECS Getting Started. Also configured HTTPS and it can be accessed at https://my-application/
Now I am trying to deploy API server (:8081). I created a new task definition and created a new service by following this tutorial - https://www.youtube.com/watch?v=3Kr_455zMk4
I chose 80:HTTP for Production listener port and same load balancer name with React client, created a new target group: ecs-default-cluster-server-api. Path pattern: /server-api* and 1 for Evaluation order. However it does not work for me.
I want to deploy server API at https://api.my-application/ or any other suitable path. How do I do it?

Environment Tier: Web Server or Worker for Setting up Elastic Beanstalk TVM?

The tutorial for Token Vending Machine for Anonymous Registration - Sample Java Web Application is out of date. In particular the current Beanstalk console has an option for Web Server or Worker (which is not covered in the tutorial) for the Environment Tier field under Environment Type. I presume for setting up a TVM I would want a server but I wanted to confirm before saving the config. So, server or worker?
Should be web server for TVM example.
AWS Elastic Beanstalk added support for worker tier in December 2013.