Elixir ranch, how to check client disconnect on transport recv?

Hello,

I like to know how I can check the client disconnect when I recv with rach, but without check the timeout.

In this case the client can keep 10 min without send any message just receiving, so the recv timeout is 10 minutes, but I need a way to know when the client is closed (the user close the client) to close the server socket

Grettings!

NOTES: I cannot edit the client to send a message or whatever when its closed

Been hacking on a telnet server the last few days, so I actually know this one, I think!

Ranch Callbacks

recv(CSocket, Length, Timeout) → {ok, Packet} | {error, closed | timeout | atom()}

If the client closes the connection or loses connectivity, you’ll get back an {:error, :closed} tuple.

1 Like

It works! so many thanks!