前提・実現したいこと
現在、Action Cableを用いたリアルタイムテキストチャット機能のついたサービスを作ろうとしています。
インフラはAWSでALBを用いて冗長化しているので、EC2のAPサーバーをElasticacheにつなげています。
他に必要なコードなどがあればおっしゃってください。
ご教授いただけると幸いです。
よろしくお願いします。
発生している問題・エラーメッセージ
チャットルームで送信した時のエラーがこのように出ています。
Could not execute command from ({"command"=>"message", "identifier"=>"{"channel":"ChatRoomChannel","chat_id":1}", "data"=>"{"text":"テスト","chat_id":1,"user_id":7,"action":"chat"}"}) [ArgumentError - invalid uri scheme '']: /var/www/myapp/shared/bundle/ruby/2.6.0/gems/redis-4.1.3/lib/redis/client.rb:438:in _parse_options' | /var/www/myapp/shared/bundle/ruby/2.6.0/gems/redis-4.1.3/lib/redis/client.rb:83:in
initialize' | /var/www/myapp/shared/bundle/ruby/2.6.0/gems/redis-4.1.3/lib/redis.rb:45:in new' | /var/www/myapp/shared/bundle/ruby/2.6.0/gems/redis-4.1.3/lib/redis.rb:45:in
initialize' | /var/www/myapp/shared/bundle/ruby/2.6.0/gems/actioncable-5.2.4.1/lib/action_cable/subscription_adapter/redis.rb:16:in `new'
該当のソースコード
environment/production.rb
ruby
1 config.action_cable.allowed_request_origins = [ 'https://myapp.com', /https://myapp.com.*/,'http://myapp.com', /http://myapp.com.*/ ] 2 config.action_cable.disable_request_forgery_protection = true
routes.rb
ruby
1mount ActionCable.server => '/cable'
cable.yml
production: adapter: redis port: 6379 url: <%= ENV['REDIS_URL'] %>
nginx
1location /cable { 2 proxy_pass http://app_server; 3 proxy_http_version 1.1; 4 proxy_set_header Upgrade websocket; 5 proxy_set_header Connection Upgrade; 6 proxy_set_header X-Real-IP $remote_addr; 7 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 8 }
試したこと
environt/production.rbにconfig.action_cable.urlで設定したりもしましたがうまく動きません。
EC2内でElasticacheとの接続はしています。
補足情報(FW/ツールのバージョンなど)
Ruby 2.6.3
Rails 5.2.4.1
AWS(EC2, Elasticache, ALB)