Websockets with AWS and Elastic Beanstalk

后端 未结 5 764
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-02 17:20

I\'m trying to get my websockets working with Amazon Web Service and Elastic Beanstalk (ELB).

I set up a proxy protocol according to: http://docs.aws.amazon.com/Elastic

相关标签:
5条回答
  • 2021-02-02 17:55

    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.

    0 讨论(0)
  • 2021-02-02 17:58

    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.

    0 讨论(0)
  • 2021-02-02 18:04

    This is a very old post but having searched around for answers on this I have found two things you need to do to get websockets on a custom port working with AWS EB.

    1. Under the configuration of your EB environment. Go to Software and add an environment variable there. Make sure this is a case sensitive match with your code.

    2. Again under the configuration of your EB environment. Go to Load Balancer and add the custom port as a listener.

    Make sure you save the new listener under the config and on reload it should be routing websocket traffic on a custom port

    0 讨论(0)
  • 2021-02-02 18:18

    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.

    0 讨论(0)
  • 2021-02-02 18:19

    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/

    0 讨论(0)
提交回复
热议问题