Deploying Rails with ActionCable to AWS Elastic Be

2019-07-30 03:43发布

问题:

I'm trying to deploy a Rails 5.1.4 application to AWS Elastic Beanstalk and cannot get ActionCable to work. There appears to be a problem with upgrading the HTTP connection to a WebSocket, as per the Rails logs:

I, [2017-11-29T20:53:23.533734 #6275]  INFO -- : [014bad33-65a1-489e-9108-dc4157965491] Started GET "/cable" for 24.192.57.23 at 2017-11-29 20:53:23 +0000
I, [2017-11-29T20:53:23.534481 #6275]  INFO -- : [014bad33-65a1-489e-9108-dc4157965491] Started GET "/cable/"[non-WebSocket] for 24.192.57.23 at 2017-11-29 20:53:23 +0000
E, [2017-11-29T20:53:23.534582 #6275] ERROR -- : [014bad33-65a1-489e-9108-dc4157965491] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: close, HTTP_UPGRADE: )
I, [2017-11-29T20:53:23.534721 #6275]  INFO -- : [014bad33-65a1-489e-9108-dc4157965491] Finished "/cable/"[non-WebSocket] for 24.192.57.23 at 2017-11-29 20:53:23 +0000

The Elastic Beanstalk configuration uses an ALB (not an ELB) which is supposed to work with WebSockets out-of-the-box.

I've tried using an ELB with TCP instead of HTTP, configuring nginx reverse proxy , and modifying application settings all without success. There seems to be consensus around the reverse proxy but I can't seem to get the incantation correct.

Please help!