Websockets with AWS and Elastic Beanstalk

非 Y 不嫁゛ 提交于 2019-12-02 22:26:45

After configuring EC2 Security group your application will work with public IP.

But you still will get issue with using EB URL. To solve this issue, you have to change EB configuration.

  1. Go to EB environment page
  2. Configuration
  3. In Load Balancing section change protocol from HTTP to TCP.

Now you can click EB URL.

AWS has launched new Application Load Balancer that supports web sockets. Change your ELB to Application Load Balancer and that will fix your issue.

https://aws.amazon.com/blogs/aws/new-aws-application-load-balancer/

You should create reverse proxy for Nginx server. You can include this config file in you .ebextensions folder to make Nginx support WS.

Also in the EBS's load balancer configuration change the protocol from HTTP to TCP.

Refer this blog to set up secure WebSocket.

I was also looking for possible workaround for this issue, but it's quite easy irrespective of what platform language you are using to develop websocket program on AWS EC2, as am using Node.js nginx in my case, this should work for all supporting platforms.

Configure Security Group

  1. In the AWS console, open the EC2 tab.
  2. Select the relevant region and click on Security Group.
  3. You should have an elasticbeanstalk-default security group if you have launched an Elastic Beanstalk instance in that region for your app.
  4. click on Actions button at top, and select Edit inbound rules.
  5. here in Type column select All TCP, or you can set some Custom TCP rule as well to listen at your websocket port.

    And that's it!

Note: If something is not working, check the "Events" tab in the Beanstalk application / environments and find out what went wrong.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!