1

I'm having issues with ActionCable on nginx (with passenger) server. When I open a page with ActionCable the server blocks all other requests. I found this issue Rails - Server Blocking on Action Cable where the exact same problem is described, but the solution didn't help.

My nginx config

server {
    listen *:8020 ssl;
    server_name my-domain.com;
    root /var/www/my-domain/current/public;
    passenger_enabled on;
    passenger_app_env beta;
    passenger_app_group_name my-domain_action_cable;
    passenger_app_type rack;
    passenger_startup_file cable/config.ru;
    passenger_force_max_concurrent_requests_per_process 0;

        ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem; $
        ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem$
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


server {
        # ssl on;
        listen         *:443 ssl;
        server_name my-domain.com;
        passenger_enabled on;
        passenger_app_env beta;
        root /var/www/my-domain/current/public/;

        ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem; $
        ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem$
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

/cable/config.ru:

require ::File.expand_path('../../config/environment', __FILE__)
Rails.application.eager_load!

run ActionCable.server

cable.yml:

beta:
  adapter: redis
  url: redis://localhost:6379/1

ActionCable config from environment file:

 config.action_cable.url = 'wss://my-domain.com:8020'

js that conects to ActionCable (using actioncable-vue)

Vue.use(ActionCableVue, {
  debug: true,
  debugLevel: 'error',
  connectionUrl: 'wss://my-domain.com:8020',
  connectImmediately: false,
}) ;

myChannel.rb:

class MyChannel < ApplicationCable::Channel
  def subscribed
    stream_from "my_channel_#{params[:id]}"
  end

  def unsubscribed
  end

  def broadcast_data(data)
    ActionCable.server.broadcast("my_channel_#{params[:id]}", data)
  end
end

My guess is that the problem lies somewhere in nginx config, but I can`t figure it out.

I followed this guide for running action cable on a different server and port (I already tried running it on the same server, the problem was still there)

Jakub Jurník
  • 11
  • 1
  • 1

0 Answers0