I am totally new to sockets and its my first time using them. I have very simple config. In endpoint
I have simple default user socket.
socket "/socket", ApiWeb.UserSocket,
websocket: true,
longpoll: false
In user socket I have the following code:
def connect(%{"token" => token}, socket, _connect_info) do
case Nuton.Guardian.resource_from_token(token) do
{:ok, user, _claims} ->
{:ok, assign(socket, :current_user, user)}
{:error, _reason} ->
:error
end
end
def id(socket),
do:
"#{socket.assigns.current_user.phone_number || socket.assigns.current_user.email}:#{
socket.assigns.current_user.id
}"
When I try to test it with any online websocket client with the following url:
ws://localhost:4000/socket
It won’t work and In the console I will get error message that
no route found for GET /socket
. I don’t understand why it’s hitting the router and not the socket. Is there anything else I need to do.
Thanks
@idi527