Websocket Using Golang Gorilla(Framework) on ECS fargate exposed through ALB.I am getting 404! Works locally though.

0

Hi I am deploying an app on ECS fargate container as service that used websocket to initiate chat sessions. I am facing some challenges in terms of making it work.

What I made sure before I ask this question: My security groups are allowing all the traffic that is needed for app to work. I have turned on Stickiness in Target group. I also turned on Session Stickiness at Group level. My health check on port 8080(/health) works fine.

I was wondering if I am missing something either in Gorilla framework(some setting or config) or AWS ALB settings that is causing 404.

Looking for help ! Regards Bhanu

1개 답변
0

Hi Bhanu,

First of all, what you're trying to do is perfectly feasible with the configuration you've mentioned, so don't give up - it's probably a configuration problem somewhere.

Now here are a few things to test/check:

  • WebSocket Support on ALB

Application Load Balancers do support WebSocket traffic, but you need to ensure that the 'Connection' header is set to 'Upgrade' and the 'Upgrade' header is set to 'websocket' during the WebSocket handshake. You can see some header example here

  • WebSocket Path in the Application

As 404 is a NOT FOUND HTTP error, ensure that the WebSocket endpoint path is correctly specified in the ALB listener rules and that it matches the path configured in your Golang application using the Gorilla framework

  • Look at the logs

One thing to try is to connect directly to the WebSocket service of one of your fargate task to bypass the ALB and to rule out any issues with the ALB configuration. If you cannot make it work, check the logs.

If websocket are working from ECS standpoint, then you can enable [ALB access Logs] (https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html) to get more insight into the requests that are reaching the ALB and how they are being handled.

Good luck !

profile pictureAWS
답변함 4달 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인