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

已提問 4 個月前檢視次數 320 次
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
專家
已審閱 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南