I am using actioncable for a chat feature. It works perfectly when I test locally, but when I deploy to Heroku I get this error:
'WebSocket connection to 'wss://dg-automotive-portal- rails.herokuapp.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404'
production.rb:
config.action_cable.url = 'wss://dg-automotive-portal-
rails.herokuapp.com/cable'
config.action_cable.allowed_request_origins = [
'https://dg-automotive-portal.herokuapp.com/', 'http://dg-
automotive-portal.herokuapp.com/' ]
cable.yml:
production:
adapter: redis
url:redis:MYURL
routes.rb has
mount ActionCable.server => '/cable'
And I have the redis gem installed. Does anyone know why this doesn't work when I deploy?
Javascript code called on componentWillMount:
createSocket() {
let cable = Cable.createConsumer('wss://dg-automotive-portal-rails.herokuapp.com/cable')
this.chats = cable.subscriptions.create({
channel: 'ChatChannel'
}, {
connected: () => {
console.log("connected!")
},
received: (data) => {
this.setState({
chatLogs: [...this.state.chatLogs, data]
})
},
create: function(chatContent, datetime, currentUser) {
this.perform('create', {
content: chatContent,
time: datetime,
user_id: currentUser
})
}
})
}