actioncable

Authenticating ActionCable connections

半腔热情 提交于 2019-12-19 03:39:07
问题 I've found a wonderful ActionCable gem, which is a good solution for SPA. I want to send only the html , css and js assets, all other connections will be implemented through ActionCable . It's not difficult to exchange strings or integers, but how can I login through ActionCable? 回答1: From the Readme # app/channels/application_cable/connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect self.current_user = find_verified

NGINX configuration for Rails 5 ActionCable with puma

对着背影说爱祢 提交于 2019-12-18 12:18:58
问题 I am using Jelastic for my development environment (not yet in production). My application is running with Unicorn but I discovered websockets with ActionCable and integrated it in my application. Everything is working fine in local, but when deploying to my Jelastic environment (with the default NGINX/Unicorn configuration), I am getting this message in my javascript console and I see nothing in my access log WebSocket connection to 'ws://dev.myapp.com:8080/' failed: WebSocket is closed

ActionCable on production: Error during WebSocket handshake: Unexpected response code: 404

冷暖自知 提交于 2019-12-13 16:16:19
问题 Everything works fine on my local machine in development mode but on production server when trying to use ActionCable I get: WebSocket connection to 'wss://example.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404 Have I forgot something? I'm running Puma on Nginx. /etc/nginx/nginx.conf: user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp

ActionCable: One channel per user

妖精的绣舞 提交于 2019-12-13 12:08:27
问题 I am working on notifications for my rails app. There is User model and controller and Like model associated to User with a User has many Likes association. The idea is, if a user likes the profile of another user, owner of the profile will get a live notification. This is my app for understanding ActionCable. I studied the cable api, pub-sub was new to me. I was able to make successful communication through a single channel, and also successfully used the authorization. But, still I don't

Deploying Rails ActionCable using AWS Elastic Beanstalk

淺唱寂寞╮ 提交于 2019-12-12 12:37:29
问题 I'm trying to deploy the chat demo from DHH on AWS Elastic Beanstalk. I've followed the tutorial here: https://keithpblog.wordpress.com/2015/12/30/rails-5-tutorial-chat-app-can-we-deploy-it And I've managed to get the solution deployed in a single instance and Redis up and running too. But when I try to post something, the message is saved in the db, but not returned by the WebSocket. I've checked the production.log and I can see this error message: E, [2016-05-20T20:33:52.676577 #24281]

ActionCable not connecting during capybara-webkit feature spec

混江龙づ霸主 提交于 2019-12-12 11:15:07
问题 I have a problem using actioncable with feature specs using Capybara-webkit. Actioncable is working perfectly on my development server, but when testing the javascript cant seem to connect. This is the output from the javascript console which is running during my feature spec WebSocket connection to 'ws://127.0.0.1:32789/cable' failed: Unexpected response code: 200 This is the output of my test.log at that moment GET "/cable" for 127.0.0.1 at 2017-01-26 13:33:23 +0000 GET "/cable/" for 127.0

Using ActionCable with multiple identification methods

一曲冷凌霜 提交于 2019-12-12 10:54:25
问题 I develop a Ruby on Rails 5.1 application using ActionCable. User authentification via Devise works fine for several channels. Now, I want to add a second type of channels which does not require any user authentification. More precisely, I would like to enable anonymous website visitors to chat with support staff. My current implementation of ApplicationCable::Connection for authenticated users looks like this: # app/channels/application_cable/connection.rb module ApplicationCable class

How to call ActionCable method from controller or model - “uninitialized constant QuizSession::App” Error

橙三吉。 提交于 2019-12-12 04:11:38
问题 I'm trying to write a simple quiz app with Ruby on Rails with 2 users, who get to see different views: the quiz hoster view shows the current question and a "next question"-button (which he is supposed to project onto a wall for the audience) and the participant view shows the 4 buttons with answer options corresponding to the current question (so the audience can participate in the quiz from their smartphones). I'm at the point, where I'm trying to use ActionCable to broadcast these 4 answer

How to ensure the javascripts/channels/chatrooms.coffee is loading and receive: (data) works? Console.log data is not loading

倖福魔咒の 提交于 2019-12-11 17:38:42
问题 Here is the file, containing what should receive from the Message Relay Job that successfully loads on the server. App.chatrooms = App.cable.subscriptions.create "ChatroomsChannel", connected: -> # Called when the subscription is ready for use on the server disconnected: -> # Called when the subscription has been terminated by the server received: (data) -> console.log(data) active_chatroom = $("[data-behavior='messages'][data-chatroom-id='#{data.chatroom_id}']").append("<div><strong>#{data

Page-specific ActionCable

喜你入骨 提交于 2019-12-11 11:13:09
问题 Curious what the best practice is for using ActionCable with Turbolinks, when you want to tie a channel with the page being viewed. The classic example, of course, if you had an article with comments -- how can you stream only those comments related to the article in view and then subscribe to a different channel when viewing a different article? I've played around with using turbolinks:loaded event on JQuery, but cant figure out what to link that to. Do I want to resubcribe every time? How