How to use websocket in an Aws Beanstalk hosted application

Asked

Viewed 62 times

0

I have a system running on aws Beanstalk, is a Java application with architecture Tomcat + Spring. I’m finding it difficult to make the websocket work, that locally is functional. The websocket receiver meets at the url dominio/socket, and the client connection is done in javascript as follows:

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

In aws the app runs on Elastic Beanstalk, with a application load balancer.I tried several ways to make it work, however I have the following feedback: inserir a descrição da imagem aqui

Some information about current environment:

  • Doors 80, 8080 and 443 are open in the load;
  • I created a target groups, enabled Stickiness and associated to load Alancer on path /socket http and https protocols;
  • https is configured with certificate generated by aws;
  • Load balancer manages 2 instances.

I’m running out of alternatives, I’ve done a lot of research and tried to replicate some ideas, however unsuccessful so far. I don’t know if the fact that there is a load balancer with two instances invalidates the current architecture.

I ask for some suggestion for the question and/or sharing of using websocket in aws with similiar artquitetura.

Thank you.

1 answer

0


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

Starting from the architecture presented in the question, I made the following adjustments:

  • I released the door 8080 in the TCP protocol (Type "Custom TCP Rule"). I therefore added a rule in the inbound and outbound security group associated with the load Alancer in question;
  • I created a new "target group" associated with port 8080 and attributes I checked the option "Stickiness";
  • I associated the target group created with load 8080 path port related to websocket end point.
  • I changed the source code to specify the connection port with websocket, for example: wss://[dominio]:8080/[end_point]

Once this configuration has been set up the application has been connected via websocket with the load Alancer application on aws.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.