[erlang-questions] ssl_closed not always received
Khitai Pang
khitai.pang@REDACTED
Mon Apr 11 11:20:22 CEST 2016
On 2016/4/11 16:23, Roger Lipscombe wrote:
> On 10 April 2016 at 22:34, Khitai Pang <khitai.pang@REDACTED> wrote:
>> How to make sure that the server process always get ssl_closed when the
>> client process on a remote host quits?
> In the general case, you *can't*. This is due to the vagaries of TCP.
> To close a socket, the client will send a FIN packet to the server. If
> the network connection is lost (consider simply unplugging the cable),
> then the FIN will *never* arrive. If you need to know when the client
> has gone away, either implement some kind of application-level
> keepalive
some kind of heartbeat?
> or enable TCP keepalive.
I already have "ok = ssl:setopts(Socket, [{keepalive, true}, ..." on
both server and client, but still ssl_closed is not guaranteed.
Since we can never be sure about whether a socket is closed, should we
use try ... catch for every ssl:send to catch {error, closed}? What is
the best practice here?
Thanks
Khitai
More information about the erlang-questions
mailing list