Hey guys! I'm trying to run ActionCable in Rails 5 with Passenger 5.0.22. So far, no luck.
First off, I tried setting up two servers in Nginx using Passenger to load the Rails
config.ru and the ActionCable
config.ru separately on a different port.
Here's my Nginx config:
server {
listen 80;
server_name 192.168.1.30;
passenger_enabled on;
rails_env production;
root /home/deploy/actioncable-example/public;
}
server {
listen 28080;
server_name 192.168.1.30;
passenger_enabled on;
rails_env production;
root /home/deploy/actioncable-example/cable/public; # Try to set it up to load the cable/
config.ru for ActionCable
}
The problem with this is that I get a "Sending 502 response: application did not send a complete response" in /var/log/nginx/error.log each time that ActionCable's client side JS tries to connect to the websocket.
Client side reports "WebSocket connection to 'ws://
192.168.1.30/cable' failed: WebSocket is closed before the connection is established." as expected when receiving the 502.
Also I've tried mounting ActionCable to a URL using config/routes.rb to no avail (and updating the URL in the JS for the websocket accordingly).
mount ActionCable.server => "/cable"
My understanding was this approach would remove the need to run two separate servers in your nginx config. (Correct?)
On Twitter, someone from Phusion replied to my question and mentioned they did successfully get this working (
https://twitter.com/phusion_nl/status/681826248121782272). I've also tested the faye-websocket demo you guys have and that does correctly work. So I'm not entirely sure what needs to be fixed here, could be an ActionCable problem or a Passenger problem.
Any ideas what might be going wrong?