Ванильное приложение Rails 6 выдает эту ошибку:
"WebSocket connection to 'ws://localhost:3000/cable' failed: WebSocket is closed due to suspension"
Канал Actioncable:
#app/javascript/channels/chat_channel.js
import consumer from "./consumer"
consumer.subscriptions.create("ChatChannel", {
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)
// Called when there's incoming data on the websocket for this channel
}
});
Контроллер Rails:
#app/controller/messages_controller:
puts "*******Broadcasting"
ActionCable.server.broadcast("chat_channel", content: @message.id)
Канал ActionCable:
# app/channele/chat_channel.rb
class ChatChannel < ApplicationCable::Channel
def subscribed
puts "**** ChatChannel Subscribed"
stream_from "chat_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
Куда я подскользнулся?