"In general, there is no foolproof way to detect a peer that went away without terminating the connection. The best you can do are heuristics like "at least one message every two minutes." "
Wow, OK. Thanks for the quick reply. I would have imagined that the uv_write call would fail or I would get a 'on disconnected' callback or something of the sort. So you literally have to keep your own heartbeat messages going with libuv? On Thursday, July 20, 2017 at 3:38:14 AM UTC-7, Ben Noordhuis wrote: > > On Thu, Jul 20, 2017 at 12:54 AM, Lubo Astinov <[email protected] > <javascript:>> wrote: > > Hello group, > > > > I have a system build on libuv and I'm having a peculiar problem. It's > > running a server and clients connect over tcp with it, but even though I > > have tcp_keepalive on the client when the server dies the client still > > thinks it's connected, there's no callback triggered etc. > > > > Essentially, I have a unit test that starts the server, starts a client, > > they exchange a handshake and a message then the server dies and the > client > > tries to write to the stream again. The uv_write() call succeeds (?!) > even > > though the server is most certainly dead at that point (I assert that > the > > object is destroyed) . The client enables tcp_keepalive but it doesn't > > cause any callback to be triggered when the server dies. > > > > I wonder if I'm missing something fundamentally here? How should I > register > > a tcp client for a notification when the server dies? Whats the best way > of > > monitoring the health of a connection? > > > > Thanks! > > Lubo > > Keep-alive does the opposite of what you want: it keeps the connection > going long after the other end has stopped responding. > > In general, there is no foolproof way to detect a peer that went away > without terminating the connection. The best you can do are > heuristics like "at least one message every two minutes." > -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
