4

For context, I've already tried to implement many answers regarding nginx (such as this one) to no success. This appears to be an issue related to nginx that isn't explored in other answers.


Using Rails 5.2 and Docker on a multicontainer EBS, WebSocket connections are failing. This failure only occurs when deployed and the same configuration works as expected locally.

I am using the Postgres adaptor with ActionCable

Problem Description:

My website is deployed to EBS and displays information just fine. My Postgres instance is connected and working as expected. However, these errors occur on WebSocket enabled pages:

In browser:

When I go to my SSL enabled site, a notice appears in the JS console:

The connection to wss://redacted.com/cable was interrupted while the page was loading.
Firefox can’t establish a connection to the server at wss://redacted.com/cable.

(This message repeats every ~5s)

Rails server logs:

Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, HTTP_UPGRADE: )
Finished "/cable/"[non-WebSocket] for <redacted IP> at 2018-02-28 02:49:03 +0000

(This message repeats every ~5s)


Prior research

Error codes:

Others in this situation note that their console throws a 400 - Bad handshake error (or similar). This is not the case here.

nginx (important):

As well, others seem to think that nginx is to blame. However, I cannot access nginx within my EBS instance. Any call for nginx results in service nginx not found and any modification of an nginx file via .ebextensions fails.

It's worth noting that I have no nginx Docker image or configuration whatsoever. I'm trying to modify EBS' built-in nginx configuration. To get to this point (where my website loads but WebSockets don't work), I have not configured nginx at all.


Troubleshooting steps taken

  • Changed EBS load balancer from HTTP to TCP
  • Modification of nginx (see above)
  • Specifying the ActionCable server URL in my production.rb
  • Specifying allowed WebSocket hosts in production.rb
  • Changing cable.yml adapters and hosts
Kieran E
  • 3,616
  • 2
  • 18
  • 41
  • 1
    It sounds like you are using a Classic ELB, rather than an [Application Load Balancer](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-applicationloadbalancer.html). Check this? – Michael - sqlbot Feb 28 '18 at 20:48
  • @Michael-sqlbot That seems to have done it! Thank you so much! If you make this into an answer, I'll vote it as winner – Kieran E Feb 28 '18 at 21:34

0 Answers0