0

I did all the steps that are required to get action cable up and running, uncommenting cable lines, creating channels, installing redis ..etc but it all fails because of this line

App.cable = ActionCable.createConsumer()

I making invalid requests to the site since I'm operating within virtualbox. and even action cable logging isn't working

module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user
def connect
  puts "YOU ARE CONNECTED "
  self.current_user = find_verified_user
  logger.add_tags 'ActionCable', current_user.email
end

protected

def find_verified_user # this checks whether a user is authenticated with devise
  if verified_user = env['warden'].user
    verified_user
  else
    reject_unauthorized_connection
  end
    end
  end
end

I'm pretty sure is vagrant issue but I don't know how to fix it,

here is my vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
  config.vm.box      = 'ubuntu/wily64'
  config.vm.hostname = 'rails-dev-box'
  config.vm.network :forwarded_port, guest: 3000, host: 3000
  config.vm.network :forwarded_port, guest: 5432, host: 15432
  config.vm.network :forwarded_port, guest: 6379, host: 6379

  config.ssh.forward_agent = true

  config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true

  config.vm.provider 'virtualbox' do |v|
    v.memory = 1024
    v.cpus = 2
  end
end

bootstrap.sh just install rvm / rails/ postgres ..etc

I even turned off my firewall. I mean the meta tag is correct

<meta name="action-cable-url" content="/cable">

when I run App.cable, I get this

url:"ws://localhost:3000/cable" connection: {disconnected: true}

I have this in my route.rb

  mount ActionCable.server => '/cable'

my cable.js is

//= require action_cable
//= require_self
//= require_tree ./channels

(function() {
  this.App || (this.App = {});

  App.cable = ActionCable.createConsumer();

}).call(this);

and rails console doesn't show actioncables logs

and I use rails 5 default server:

=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.2.5-p319), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop 
Medo
  • 335
  • 1
  • 3
  • 14

0 Answers0