How to use websocket in Aws Beanstalk hosted application

0

I have a system running on aws beanstalk , it's a Java application with Tomcat + Spring architecture. I'm having trouble making the websocket work, which is locally functional. The websocket receiver answers to url dominio/socket , and the client connection is done in javascript as follows:

new WebSocket("wss://dominio/socket");

In aws the application runs on elastic beanstalk, with an application load balancer . I tried in several ways to make it work, however I have the following return:

Some information about the current environment:

  • Ports 80, 8080, and 443 are open in the load balancer;
  • I created target groups, enabled Stickiness, and associated the load balancer in path /socket in the http and https protocols
  • https is configured with aws-generated certificate;
  • The load balancer manages 2 instances.

I'm running out of alternatives, I've done a lot of research and tried to reproduce some ideas, but with no success so far. I do not know if having a two-instance load balancer invalidates the current architecture.

I ask for some suggestion for the issue and / or sharing of websocket usage in aws with similar art.

Thank you.

    
asked by anonymous 04.09.2018 / 02:35

1 answer

0

I was able to solve the problem, I will add the solution adopted because it can be useful to other people.

Based on the architecture presented in the question, I made the following adjustments:

  • I released the 8080 port in the TCP protocol (Type "Custom TCP Rule"). I have added a rule inbound and outbound in the security group associated with the load balancer in question;
  • I created a new target group associated with port 8080 and in the attributes I marked the Stickiness option;
  • I linked the target group created to the load balancer to intercept requests from the 8080 port of the path related to the endpoint of the websocket .
  • I changed the source code to specify the connection port with websocket, eg wss://[dominio]:8080/[end_point]

Once this configuration has been made, the application has passed the websocket connection with the load balancer application in aws.

    
06.09.2018 / 14:09