1

I have a Rails 7 application running action cable and cable ready on linode. It works fine locally.

However, on staging action cable does not work.

Started GET "/cable" for 109.155.210.18 at 2023-06-22 15:24:01 +0100
Started GET "/cable" [WebSocket] for 109.155.210.18 at 2023-06-22 15:24:01 +0100
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
WebSocket error occurred: wrong number of arguments (given 2, expected 1)
WebSocket error occurred: wrong number of arguments (given 2, expected 1)
WebSocket error occurred: wrong number of arguments (given 2, expected 1)
nginx version: nginx/1.14.0 (Ubuntu)
Phusion Passenger 6.0.1
rails (7.0.4.3)
ruby 3.2.0
actioncable (= 7.0.4.3)
cable_ready (= 5.0.0)
websocket-driver (0.7.5)

cable.yml

staging:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
  channel_prefix: wdpa

channel.rb

module ApplicationCable
  class Channel < ActionCable::Channel::Base
    include CableReady::Broadcaster
  end
end

connection.rb

module ApplicationCable
  class Connection < ActionCable::Connection::Base
  end
end

environments/staging.rb

  config.cache_store = :redis_cache_store, {
    driver: :hiredis,
    url: ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" }
  }

  config.session_store(
    :redis_session_store,
    key: "_session_staging",
    serializer: :json,
    redis: {
      driver: :hiredis,
      expire_after: 1.year,
      ttl: 1.year,
      url: ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" }
    }
  )

nginx config

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/:app_name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/:app_name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /cable {
  passenger_app_group_name wdpa_action_cable;
  passenger_force_max_concurrent_requests_per_process 0;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}

Tried: experimented with config, failed

ActionCable in ElasticBeanstalk fails with untraceable error

0 Answers0