I am running a rails 5 application as a backend server and an ember application for an external application. These are two separate applications hosted on two different domains - for example, backend.devandfrontend.dev
The rails application has a simple connection class found in app/channels/application_cable/connection.rbthat looks like this:
module ApplicationCable
class Connection < ActionCable::Connection::Base
def connect
Rails.logger.debug("env: #{env.inspect}")
Rails.logger.info("cookies.signed: #{cookies.signed.inspect}")
end
end
end
I have a simple base channel class in app/channels/application_cable/channel.rbwith the following:
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
And one implementation of this class in app/channels/events_channel.rb:
class EventsChannel < ApplicationCable::Channel
def subscribed
Rails.logger.debug("env: #{env.inspect}")
Rails.logger.info("cookies.signed: #{cookies.signed.inspect}")
stream_from 'events'
end
end
On the other hand, I am using an ember cable package. I configured my consumer in my interface by extending the controller class as follows:
cableService: Ember.inject.service('cable'),
setupConsumer: Ember.on('init', function() {
let service = this.get('cableService');
let consumer = service.createConsumer(`ws://backend.dev`);
let channel = 'EventsChannel';
consumer.subscriptions.create(channel, {
disconnected() {
Ember.debug(`${channel}#disconnected`);
},
connected() {
Ember.debug(`${channel}#connected`);
},
I am sure my consumer is configured correctly, as I see some debug output when I get the following output to the js console:
DEBUG: EventsChannel
:
WebSocket connection to 'ws://backend.dev/' failed: Error during WebSocket handshake: Unexpected response code: 200
, , rails. - , ? , 200?