[Haskell-cafe] Network Connect Timeouts
Joachim Durchholz
jo at durchholz.org
Sat Oct 14 09:35:49 UTC 2017
I do not have an answer to your actual question, just a side node on
your workaround:
Am 14.10.2017 um 04:14 schrieb Mark Fine:
> As a workaround, I'm spinning trying to successfully connect first
> before trying to connect for real:
This does not give you the effect you want out of it.
Nowadays, middleboxes and servers keep track of past connections, for
various reasons - mostly it's NAT in things like cable modems, and
intrusion detection systems (IDSes) in servers or close-to-server
middleboxes.
Cable modems and similar tend to operate under memory-constrained
conditions. If you open two connections, this may be the final straw
that breaks the cable modem, causing all kinds of weird behaviour (the
better ones will drop the longest-unused connections, but I have seen
some that will start exhibiting all kinds of bugs).
This failure mode is particularly important if you plan to open many
connections from a client at the user's home; otherwise it is less relevant.
IDSes will notice that you quickly opened and closed connections, and
potentially flag this as suspicious.
The usual solution is to open the connection, and retry a few times.
(Failed connection attempts tend to be not remembered by middleboxes.)
If retrying fails, either ask the user if the program should retry
connecting (not telling the user that there were retries already, they
don't care and wouldn't understand), or if it's a server, do the retries
with an exponential standoff and log the situation once it becomes
severe enough.
Neither solution is really doable at the network connection layer, so
maybe it's actually okay if there is no answer to your original question :-)
Regards,
Jo
More information about the Haskell-Cafe
mailing list