How to disconnect a client in Action cable (rails 5)? I would like the user to be completely disconnected (similar to when he closes the tab).
I stumbled across this issue too. But I could not believe that there is no simple way to disconnect the websocket connection from the client (without doing an API call). Luckily this works for me:
// Create consumer
window.cable = ActionCable.createConsumer(...)
// Subscribe to channels
window.cable.subscriptions.create('SomeChannel', ...);
// At some point we want to disconnect (e.g. when user logs out)
window.cable.subscriptions.consumer.disconnect();