Intermittent Issues Opening websocket on AWS ECS

0

Running my Golang app using gorilla websockets in AWS ECS using Fargate and an ALB in front. A couple days ago connecting to the socket was working and then would intermittently fail. Now it is consistently failing to open the socket.

I've tried connecting through the ALB with and without the port as well as connecting to the public ip the ECS Task is running on.

The error my app is logging: websocket: the client is not using the websocket protocol: 'upgrade' token not found in 'Connection' header

Headers that my app receives, the connection header is somehow missing by the time my app handles the request

{ "Sec-Websocket-Extensions": [ "permessage-deflate; client_max_window_bits" ], "Sec-Websocket-Key": [ "Dlb3vf23t9rtkY+wwazr7w==" ], "Sec-Websocket-Version": [ "13" ], "Via": [ "1.1 ::ffff:172.20.32.1 (Mikrotik HttpProxy)" ], "X-Forwarded-Port": [ "80" ], "X-Forwarded-Proto": [ "http" ], "X-Proxy-Id": [ "619378727" ] }

Ways I've tried to connect:

wscat -nc ws://www.example.com/v1/ws

wscat -nc ws://www.example.com:80/v1/ws

wscat -nc ws://<public ip>/v1/ws

wscat -nc ws://<public ip>:80/v1/ws

1 Answer
0

Hello,

The shared error is related to wrong nginx configurations, which is out of scope of AWS premium support but I have shared the below links and information on best effort basis.

This issue seems to be related with the issue in nginx configurations, I could find some links where the same issue have been discussed you can check your configurations and what is missing.

https://stackoverflow.com/questions/65309160/client-is-not-using-the-websocket-protocol-upgrade-token-not-found-in-connec

https://stackoverflow.com/questions/74509802/websocket-the-client-is-not-using-the-websocket-protocol-upgrade-token-not-f

https://forum.mattermost.com/t/websocket-connect-err-error-websocket-the-client-is-not-using-the-websocket-protocol-upgrade-token-not-found-in-connection/9110

https://stackoverflow.com/questions/70210654/httpd-websocket-error-upgrade-token-not-found-in-connection-header

Have a great day ahead !

AWS
sanju_s
answered 10 months ago
  • Hi Sanju,

    Thanks for providing these links. However, I am not using nginx and only have the ALB pointing directly to the ECS cluster and was wondering if I could get this working without needing to setup nginx behind the ALB since hitting the public IP of the ECS instance already has the headers missing. Is there a way to preserve or add a header on ECS?

    Thanks

  • Hi I am hitting similar problem and I am using Gorilla as webframework to deploy an app on ECS containers. I am getting 404 and I am kinda stuck and not able to move forward. I have not set up any NGINX config for this. Based on AWS documentation,it seems that working with websockets on ALB is no big deal. Was wondering if you were able to sort this problem

  • I am having the same issue as well with a mattermost server and have configured NGINX to add the headers

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