Oct 15, 2011 at 10:37 PM
Edited Oct 15, 2011 at 10:41 PM
Well after deeping and reading some articles and oppinions for people with experience in this area, I have concluded the following ...
1.- The meaning of keepalives is not exactly what I was thinking about at beginning, reading from MSDN even tweaking "Keepalivetime" to 30 seconds and "keepaliveinterval" to 1 second I have to wait for each retransmission before a not existed connection
is really thrown, each retransmission is by default 5 (I think), further, the keepinterval is duplicated automatically in each retry to later be resetted to its initial value. Exits a considerable delay before the connection is really detected as dropped on
unplug cable for example.
2.- Reading from Nito site and others web pages, We should take note that some routers or firewalls can discard packet of zero bytes, like the suggested from the example of MSDN in the connect property. Even can discard the zero size packet sent by keepalive
bringing as consecuence the bad assumption of down connections when they're really exist and active, by error you can discard good connections.
3.- Apparently if it's really necessary detect dropped connections almost inmediately or faster, We should:
3.a.) Create a time property in the class containing the socket business connection (in the server) and reset each time an info is send or receive successfully, having a thread that check periodically for time of innactivity.
3.b) Create a delegate timer in the class containing the socket business connection (in the server) and check each elapsed time per connection more accurate but is more resource consumed than the previous.
3.c) Send periodically a heartbeat (configured on client and server) to detect connection that has been dropped and discard them, in this case is necessary to take care of that the defined heartbeat do not disturb our business logic communication.
According to some people Keepalive bring more problems that solutions to them. That's the case for example of router (depending on model or any other thing) acceptance or not of zero length packets.
It's important to notice that sometimes when We discard a connection maybe We are discarding a connection that can gracefully reconnected, for example unplugging and plugging again the cable after five minutes or some time will keep the connection still
alive, or even a failure in the router and its returned activity will keep our connection working fine.
That's what I have understand, what all of you think about it? ... something wrong? more or better suggestions?