Remember about connection timeout

As a programmer I tend to think optimistically, I focus on how to make something work, not how to break them. Sometimes it results with poorly tested ‘bad scenario’ paths.

One thing about I forgot recently (again!) is to set connection timeout. Libraries often do not require setting it. Just call connect and you are done. Assumption that ‘there is probably some default timeout somewhere’ is incorrect. Often there is no timeout at all.

With infinite connection timeout, when something goes wrong your code can just hang up, without any exception or anything. It may get worse if you periodically schedule a job that then hangs up. In that case you may end up with army of zombie jobs eating your yummy resources.

*****
Written by Michał Łoński on 10 March 2021