Questions tagged [actioncable]

Action Cable is an open source technology shipped to us with Ruby On Rails 5. It uses websockets instead of traditional HTTP protocol and allows 2-way asynchronious data transfer. The best field of application for ActionCable is chat, single page applications and so on.

The Action Cable source is placed at Github.

To find code examples please check actioncable-examples repository.

849 questions
42
votes
3 answers

Request origin not allowed: http://localhost:3001 when using Rails5 and ActionCable

Having server issues with an app in Rails 5.0.0.beta2 trying to use ActionCable. Using localhost:3000 works fine, as that is what most of ActionCable defaults to. But if I try to run the rails server on port 3001, it gives me Request origin not…
daybreaker
  • 1,320
  • 1
  • 10
  • 17
39
votes
1 answer

ActionCable.server.broadcast from the console

I can use the following code in the controller but not in the console (both development environment). I'm using Rails 5.0.0.beta2. ActionCable.server.broadcast 'example_channel', message: '

Test

' The console: >> ActionCable.server.broadcast…
wintermeyer
  • 8,178
  • 8
  • 39
  • 85
27
votes
2 answers

ActionCable no longer working in production environment

I have a Rails 5 app which uses Action Cable for websocket functionality. In my development environment everything works as expected and the browser clients successfully connect to the Action Cable channels. In my production environment Action Cable…
edwardmp
  • 6,339
  • 5
  • 50
  • 77
27
votes
1 answer

ActionCable Not Receiving Data

I created the following using ActionCable but not able to receive any data that is being broadcasted. Comments Channel: class CommentsChannel < ApplicationCable::Channel def subscribed comment = Comment.find(params[:id]) stream_for…
Artem Kalinchuk
  • 6,502
  • 7
  • 43
  • 57
26
votes
9 answers

ActionCable - Failed to upgrade to WebSocket in production

ActionCable doesn't work in production. Works well in development, but not in production. Running Nginx with Puma on Ubuntu 14.04. I have checked that redis-server is up and running. Rails -v 5.0.0.1 production.log: INFO -- : Started GET…
mityakoval
  • 888
  • 3
  • 12
  • 26
26
votes
3 answers

Rails with real time notifications architecture

I need to add realtime notifications to my Rails app. Here are the different possible architectures I have found. 1. Rails + Socket.io + Redis: As suggested in this post, having the following architecture: Pro: Clean, no data is lost if Socket.io…
Augustin Riedinger
  • 20,909
  • 29
  • 133
  • 206
23
votes
3 answers

What is the difference between `stream_from` and `stream_for` in ActionCable?

The descriptions here seem to imply that stream_for is used only when passing in a record, but overall the documentation is rather vague. Can anyone explain the differences between stream_from and stream_for and why would you use one over the…
Xavier
  • 3,423
  • 23
  • 36
23
votes
10 answers

Send auth_token for authentication to ActionCable

module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect #puts params[:auth_token] self.current_user = find_verified_user logger.add_tags 'ActionCable',…
alxibra
  • 727
  • 1
  • 7
  • 12
23
votes
2 answers

How to use ActionCable as API

I built a very simple app using Rails 5 beta 1 and ActionCable to show when users come online and let them send messages to each other. Now, I would basically like to take the client-side part of ActionCable, implement it in the context of another…
sam
  • 1,711
  • 1
  • 17
  • 24
22
votes
5 answers

ActionCable - how to display number of connected users?

I'm trying to create a simple chat-like application (planning poker app) with Action Cable. I'm a little bit confused by the terminology, files hierarchy and how the callbacks work. This is the action that creates user session: class…
pmichna
  • 4,800
  • 13
  • 53
  • 90
21
votes
2 answers

How do I find out who is connected to ActionCable?

I have seen ActionCable.server.open_connections_statistics, ActionCable.server.connections.length, ActionCable.server.connections.map(&:statistics), ActionCable.server.connections.select(&:beat).count and the like, however this is only "per process"…
19
votes
1 answer

ActionCable server response times on Heroku

I've implemented a real-time chat system using ActionCable. It works, but I keep getting exception notices from Rollbar for the /cable endpoint in production (Heroku). 2017-07-18T15:36:54.738588+00:00 heroku[router]: at=info method=GET…
kid_drew
  • 3,857
  • 6
  • 28
  • 38
19
votes
5 answers

How do I get current_user in ActionCable rails-5-api app?

Why am I not able to retrieve current_user inside my channel or how should I retrieve current_user? What do I use? Rails 5.0.1 --api (I do NOT have any views NOR use coffee) I use react-native app to test this (Works fine WITHOUT authorization) I…
Saravanabalagi Ramachandran
  • 8,551
  • 11
  • 53
  • 102
18
votes
1 answer

Actioncable broadcast not working from console in Rails

I used actioncable on rails 5 app. Below code work in controller but not in console. ActionCable.server.broadcast "connector_app", content: "test message" Response: [ActionCable] Broadcasting to connector_app: {:content=>"test message"} =>…
puneet18
  • 4,341
  • 2
  • 21
  • 27
18
votes
3 answers

Connecting to ActionCable from iOS app

I have been stuck on this all day. I have the very simple ActionCable example app (the chat app) by David Heinemeier Hansson working correctly (https://www.youtube.com/watch?v=n0WUjGkDFS0). I am trying to hit the websocket connection with an iPhone…
Pan
  • 181
  • 1
  • 5
1
2 3
56 57