Justin Lee
Justin Lee

Reputation: 11

AWS ALB - Error during WebSocket handshake

I am running a tomcat/java web app on aws behind an application load balancer.

I have an WebSocket endpoint set up at "/socketserver". Locally everything works, but when web app is deployed to aws, creating an websocket client through javascript (e.g. var exampleSocket = new WebSocket("ws://www.example.com/socketserver"); returns 404 error during Websocket handshake.

Is there any additional setup required? I heard ALB supports websockets natively. Thanks.

some things I tried:

  1. creating a separate target group with path to "/socketserver", and adding additional http rule, and enabled session stickiness.

  2. changing maven websocket dependency scope to provided.

  3. checked access log, found 127.0.0.1 - - [26/Mar/2017:13:31:29 +0000] "GET /socketserver HTTP/1.1" 404 1002

Upvotes: 1

Views: 2585

Answers (2)

Michael Mitchell
Michael Mitchell

Reputation: 91

If you are using ALB and are experiencing this problem try updating your security policy, I ran into the same problem even though it was working perfectly fine in the same setup for another website but noticed the security policy was about 1 year behind. Updating it to a newer one seems to have solved the problem.

Upvotes: 0

Abdoul Ndiaye
Abdoul Ndiaye

Reputation: 193

I think that you need to activate the "Stickiness" in your target group.

You'll also need to specify the transport "websocket" for all your socket.io clients.

Upvotes: 0

Related Questions