You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use anything such as Javascript to connect to the channel
Rails console will log in loop: [#<MyChannel:0x000000013411e9c0>] Connection is active!
Refresh the browser, the thread is closed, the connection reopen and everything works as expected unless! you edit some code like add whitespace or new empty line or anything and refresh the browser. The rails console will now log twice as fast and you will notice it's coming from 2 different instances.
classMyChannelChannel < ApplicationCable::Channeldefsubscribedreject_subscriptionifparams[:session_id].blank?room_id="web_ssh_#{params[:session_id]}"stream_fromroom_id@subscribed ||= Thread.newdowhilestreams.present?Rails.logger.debug{"[#{self}] Connection is active!"}sleep1endendenddefunsubscribed@thread&.exitendend
Expected behavior
Editing the code should not prevent ActionCable from closing connections.
If you're wondering why I am using a thread, it is because i'm opening a Net::SSH connection over an ActionCable connection. This gem requires to have a loop to call process in order to process things and work properly.
# self.ssh_client ||= Net::SSH.start(...)# self.ssh_channel ||= ssh_client.open_channel do ... enddefopen_connection_thread!self.thread ||= Thread.newdowhilessh_channel.active? && streams.present?ssh_client.process(0)sleep0.05# Save CPU timeendrescueStandardError# Ignoredensuressh_channel&.closessh_client&.closeendend
The text was updated successfully, but these errors were encountered:
james-em
changed the title
[Bug][ActionCable / Zeitwerk] Code reloading doesn't close connections
[Bug][ActionCable/Zeitwerk] Code reloading doesn't close connections
Apr 18, 2024
Steps to reproduce
[#<MyChannel:0x000000013411e9c0>] Connection is active!
Expected behavior
Editing the code should not prevent ActionCable from closing connections.
Actual behavior
It appears to not close connections
System configuration
Ruby version: 3.3.0
Extra info
If you're wondering why I am using a thread, it is because i'm opening a
Net::SSH
connection over an ActionCable connection. This gem requires to have a loop to call process in order to process things and work properly.The text was updated successfully, but these errors were encountered: