Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Recieved Method in Rails does not get called and no output for console.log

$
0
0

Hello i am building a Rails app and i am working on an actioncable.I have a problem regarding the recieve Method from my channel.Im working on windows via wsl and got redis instead of async.My actioncable is registered and has a connection. It is transmitting the subscription confirmation and streaming to my channel. When i want to send data, i lose the connection and my console.log in thedisconnected() method gets called and I dont receive any data. I get the information via my browser console that the connection is lost.Anyone can give me some insight, what i can to fix that problem?

  def create    @message = Message.new(message_params)    @message.user = current_user    @message.save    ActionCable.server.broadcast("room_channel_#{@message.room_id}", {message: "hello"}  end

room_channel.rb

class RoomChannel < ApplicationCable::Channel  def subscribed    stream_from "room_channel_#{params[:room_id]}"  end  def unsubscribed    # Any cleanup needed when channel is unsubscribed  endendimport consumer from "./consumer"consumer.subscriptions.create({channel: "RoomChannel", room_id: 5}, {  connected() {    console.log("connected.... HELLO")  },  disconnected() {    console.log()    console.log("disconnected")  },  received(data) {      console.log(data)  }});

enter image description here

In the browser console i recieve the message "disconnect" when clicking a button to send data and i am using gem devise with warden_hooks.rb


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>