# Websocket server in Elixir or phoenix

**URL:** <https://forum.elixirforum.com/t/websocket-server-in-elixir-or-phoenix/51906>\
**Category:** Questions\
**Tags:** phoenix, websockets\
**Created:** [November 19, 2022, 8:42pm UTC](https://forum.elixirforum.com/t/websocket-server-in-elixir-or-phoenix/51906 "2022-11-19T20:42:01Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![RooSoft](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/roosoft/32/23241_2.png) [@RooSoft](https://forum.elixirforum.com/u/RooSoft)\
**Post date:** [February 1, 2023, 7:32pm UTC](https://forum.elixirforum.com/t/websocket-server-in-elixir-or-phoenix/51906/7 "2023-02-01T19:32:45Z")

</div>

Also figured out…

In init/1,

```elixir
Process.send_after(self(), :ping, ping_timeout)

```

Then, add a handle\_info

```elixir
  @impl true
  def handle_info(:ping, %{options: options} = state) do
    ping_timeout = Keyword.get(options, :ping)

    Process.send_after(self(), :ping, ping_timeout)

    {:push, {:ping, ""}, state}
  end

```

Will suggest the peer has to send a `PONG`, and if it does, that will count as a communication and thus will reset the timeout.

---

_[View the full topic](https://forum.elixirforum.com/t/websocket-server-in-elixir-or-phoenix/51906)._
