How to run a Parse Live Query Server (Web Sockets) behind an AWS Load Balancer

amazon-web-serviceselastic-beanstalkload balancingparse-serverwebsocket

ParseLiveQuery depends on Websockets. More generically this question could be about getting web sockets to work behind an AWS ELB.

I'm using the new Parse Server configured in AWS using Elastic Beanstalk (EB). EB configures an EC2 instance behind a Load Balancer and we need auto-scaling to work. The Parse Server is working very well.

I'm configuring our server to use the new Parse Live Query implementation which uses WebSockets.

  1. Locally I have everything working.
  2. My iOS Client app will connect and work if I connect the LiveQueryClient directly to the Public DNS of one of our ParseServer instances.
    e.g. http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com
  3. However, I'm not awesome enough to understand why our LiveQuery code doesn't work through the Load Balancer DNS entry.
    e.g. http://parseserver-xxxxxx-env.us-east-1.elasticbeanstalk.com

I'm getting a 404 error if I point the client to the Load Balancer:

Error Domain=SRWebSocketErrorDomain Code=2132 "received bad response code from server 404"

Best Answer

If it works locally - eg, going around the LB then I would guess that the LB is not configured to pass requests to the backend servers on that port. Your LB will need some new rules to route traffic to you backed hosts based on the destination port your service is listening on, see AWS for more help with this

http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-add-or-delete-listeners.html

it looks like websockets are not officially supported on AWS ELB though, so you might need use one of the current workarounds https://forums.aws.amazon.com/thread.jspa?messageID=589328