Adrian Adrian - 13 days ago 5
Ruby Question

actioncable does not work after deploy to heroku

I have just completed the action cable tutorial from the learn enough site. Everything is working fine in development but after deploying to heroku the action cables don't work. I have made sure to do the following:

(1) cable/yml

adapter: redis
url: <%=ENV['REDISTOGO_URL']%>


(2) production.rb

config.action_cable.url = 'wss://myurl.herokuapp.com/cable'
config.action_cable.allowed_request_origins = [
'https://myurl.herokuapp.com', /http://myurl.herokuapp.com.*/]


(3) routes -

mount ActionCable.server, at: '/cable'


(4) added the redis to go addons in heroku

Heroku logs shows the following errors:

Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)

Request origin not allowed: https://myurl.herokuapp.com

Didn't i just specify the allowed request url in production.rb and now its giving this error?

I am running rails 5.0 and ruby 2.3.1. Appreciate any assistance.

Answer

I think this:

config.action_cable.allowed_request_origins = [
'https://myurl.herokuapp.com', /http://myurl.herokuapp.com.*/]

should be this:

config.action_cable.allowed_request_origins = [
'https://myurl.herokuapp.com', 'http://myurl.herokuapp.com']