Rails 5 actioncable freezes the server

ruby-on-rails nginx websocket actioncable

530 просмотра

3 ответа

1064 Репутация автора

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 Источник Размещён: 19.07.2016 08:49

Ответы (3)

1 плюс

766 Репутация автора

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

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 Размещён: 11.01.2018 06:03

3 плюса

31 Репутация автора

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 Размещён: 24.03.2018 07:52

0 плюса

53 Репутация автора

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;

Автор: Darlyncinho Bravo Размещён: 27.03.2018 05:38
Вопросы из категории :