Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Deploy Rails ActionCable AWS Redis Server

$
0
0

I have a Rails/React AWS Application that uses AWS ECS. It has a chat feature that's not currently working because the ActionCable/websocket connection is not configured. However, I'm having a difficult time trying to figure out how to get ActionCable/Web Sockets working for this particular stack

The current architecture looks sort of like this:

  1. The user goes to https://myapp.com and it serves them the static react application from an S3 bucket

  2. The user makes requests from the browser that are directed to https://loadbalancer.myapp.com which directs them to one of the running tasks (rails servers)

So I've created elasticache redis cluster using AWS easy create + demo with the default settings. It has the configuration endpoint clustercfg.foo.amazonaws.com:6379

In my config/environments/production.rb I added:

config.web_socket_server_url = "wss://loadbalancer.myapp.com/cable" config.action_cable.allowed_request_origins = ['https://myapp.com', 'http://myapp.com', 'https://loadbalancer.myapp.com', 'http://loadbalancer.myapp.com']  

in my config/cable.yml I added:

production:  adapter: redis  url: clustercfg.foo.amazonaws.com:6379/1  channel_prefix: dont_think_this_matters

In my react application I have

CableApp.cable = actionCable.createConsumer("wss://loadbalancer.myapp.com/cable");

Am I missing anything? I'm not quite sure what my security group for the redis shard should look like. Is it accepting https requests to port 6739?

The console error I get when trying to connect to my chat component is:

The page at 'https://myapp.com/chat' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://loadbalancer.myapp.com/cable'. This request has been blocked; this endpoint must be available over WSS.

react-dom.production.min.js:127 Uncaught DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

But both my react app and config.web_socket_server_url are using "wss" so I'm not sure how to resolve this issue


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>