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
Hi,
Just saw the PR that implemented the reconnect! method. I am actually using it but i noticed it doesn't calls back the connected callback. What i am doing to trigger the disconnect the callback is just shutting down the ActionCable server in a different process, then turning it back on immediately.
Here is my sample code:
require 'action_cable_client'
EventMachine.run do
@connected = false
device_id = 1
uri = 'ws://localhost:3001/cable'
params = {
channel: 'DevicesChannel'
}
headers = {
:Origin => 'ws://localhost:3001/cable',
:device_id => device_id
}
client = ActionCableClient.new(uri, params, true, headers)
client.connected do
@connected = true
puts 'successfully connected.'
end
client.received do |message|
p message
end
client.subscribed do
puts "-> Subscribed!"
end
client.disconnected do
@connected = false
while !@connected
puts "-> Disconnected, trying to reconnect in 5 seconds"
sleep 5
client.reconnect!
puts "-> Client inspect: #{client.inspect}"
end
end
client.errored do |e|
@connected = false
puts "-> Errored #{e}."
end
end
I expected the reconnect method to start over all callbacks again. Maybe i need to subscribe all callbacks again? I think that would cause infinite loops.
Hi,
Just saw the PR that implemented the reconnect! method. I am actually using it but i noticed it doesn't calls back the
connected
callback. What i am doing to trigger the disconnect the callback is just shutting down the ActionCable server in a different process, then turning it back on immediately.Here is my sample code:
I expected the reconnect method to start over all callbacks again. Maybe i need to subscribe all callbacks again? I think that would cause infinite loops.
Here is my console output:
The text was updated successfully, but these errors were encountered: