Within a Phoenix Channel callback I want to close the websocket connection to a client, preferably with a custom websocket close code (such as 4000, 4006 etc.) How can I do this?
This is what I have tried so far:
- By implementing the
- By killing the transport process
Process.exit(socket.transport_pid, :kill)but this will log an error.
Is there a way to terminate the transport (which I set to :websocket) cleanly with specified websocket code 4006 from within a channel callback? I have tried to use
Process.exit(socket.transport_pid, :normal) but this seems to have no effect.