4

I am having issue running Actioncable on nginx server, every time I mount actioncable

mount ActionCable.server => '/cable'

the server will return

Started GET "/cable" for ::1 at 2016-05-24 11:42:16 -0400
Started GET "/cable/" [WebSocket] for ::1 at 2016-05-24 11:42:16 -0400
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)

before freezing

Any help is appreciated!

JayX
  • 1,754
  • 1
  • 18
  • 27
  • 1
    is this what you are searching for? http://stackoverflow.com/questions/34680836/nginx-configuration-for-rails-5-actioncable-with-puma – siegy22 Jul 19 '16 at 08:52
  • @RaVeN yea I tried what's in that post but nothing changed, thanks for the help though – JayX Jul 29 '16 at 08:18
  • @JayX Did you manage to find a solution to this? Currently having this same issue – FutoRicky Dec 30 '22 at 18:46

3 Answers3

3

I was having this same issue once my application was being used by many users. My problem came from using Puma and Phusion Passenger together. This issue was solved by eliminating Puma from my application and configuring Nginx to use Action Cable with Passenger instead.

This article outlines the correct way to configure Action Cable + Nginx + Passenger

amcritchie
  • 31
  • 3
1

I had same problem. Rails server was freezing after connecting This worked for me In config.ru file

if defined?(PhusionPassenger)
  PhusionPassenger.advertised_concurrency_level = 0
end

Idea is that set concurrency level to 0

Initially i was setting concurrency level 0 for cable server only in nginx.conf file

Hope this save someone's day

Sandeep Kapil
  • 984
  • 8
  • 14
  • Where does this go in `cable/config.ru` ? Before or after `run ActionCable.server`. Also, this fails to work if my pool size in low (6). A higher size (like 16) makes it work for me. – tambakoo Jun 12 '19 at 06:53
0

If you are using puma + nginx + rails you should use : Inside your virtual host in nginx conf

    # enables WS support
location /cable {
    proxy_pass http://cable;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto https;
    proxy_redirect off;


}
Darlyn
  • 310
  • 1
  • 2
  • 16