About the part “otherwise you just disconnect them”, do you have any ideas on how to implement it? I’m assuming you meant “disconnect if the user doesn’t authenticate in X seconds”.
What I have tried
In the user socket’s connect/3
- Schedule an
:auth_timeoutmessage usingProcess.send_after/3toself() - Save the timer reference into the socket assigns
- Handle the
:auth_timeoutand disconnects the socket.
In the user channel’s join/3
- Cancel the timer once the user authenticates.
However, Phoenix.Socket brings its own handle_info(message, state) that matches everything. So instead of sending my custom :auth_timeout, I tried sending a %Broadcast{event: "disconnect"} that I see in the source code. However, it looks the process that runs the connect/3 is not the same that would be listening for these messages, so nothing happens.
Do you know which process would it be?


















