# Testing sockets in phoenix

**URL:** <https://forum.elixirforum.com/t/testing-sockets-in-phoenix/33614>\
**Category:** Questions\
**Tags:** phoenix, web-socket\
**Created:** [August 7, 2020, 8:14am UTC](https://forum.elixirforum.com/t/testing-sockets-in-phoenix/33614 "2020-08-07T08:14:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leaf](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/l/ec9cab/32.png) [@leaf](https://forum.elixirforum.com/u/leaf)\
**Post date:** [August 7, 2020, 8:14am UTC](https://forum.elixirforum.com/t/testing-sockets-in-phoenix/33614/1 "2020-08-07T08:14:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bluejay](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/bluejay/32/20101_2.png) [@bluejay](https://forum.elixirforum.com/u/bluejay)\
**Post date:** [August 7, 2020, 1:39pm UTC](https://forum.elixirforum.com/t/testing-sockets-in-phoenix/33614/2 "2020-08-07T13:39:35Z")

</div>

What happens if you try  
`ws://localhost:4000/socket/websocket`
