I have a React + Rails app and I'm trying to configure my web application to use ActionCable. I've been struggling for several days with getting my websocket connection to work.
My server log doesn't show any output aside from "Loading up and listening on http://0.0.0.0:3000.." but it's possible that I don't have it configured right. I'm using ECS with fargate, so I don't think it's possible to ssh into any of the instances
The only error message I see in the browser log is:
WebSocket connection to 'wss://loadbalancer.liverapcenter.com/cable' failed:
The architecture works like this:
The user goes to https://myapp.com and it serves them the static react application from an S3 bucket
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)
I 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/cable.yml I added:
production: adapter: redis url: redis://clustercfg.foo.amazonaws.com:6379 channel_prefix: dont_think_this_matters
In my config/environments/production.rb I have:
config.action_cable.mount_path = "/cable"config.action_cable.url = "wss://loadbalancer.liverapcenter.com/cable"config.action_cable.allowed_request_origins = ['*']
In my react app I have
const actionCableEndpoint = 'wss://loadbalancer.liverapcenter.com/cable';CableApp.cable = actionCable.createConsumer(actionCableEndpoint);
In my network tab, all my normal HTTPS requests to the sever work fine and it looks like there are continuous connections being made to /cable over wss:// every n seconds (which I think is to be expected), but the socket connection doesn't work.
In case anyone is interested, I have even more information about my AWS configuration and an example of the issue: