amqplib
amqplib copied to clipboard
Introduce post-connection timeout setting
Currently, the timeout for the underlying socket is reset to 0 after a successful connection. This can lead to promises hanging indefinitely / callbacks not being invoked in case the server becomes unresponsive. On the other hand, just using the default socket timeout may be too short, and introduce runtime errors.
As a solution, this change introduces a second socket option postConnectTimeout which is being applied to the socket after a successful connection, rather than resetting the timeout to 0. If the setting is not provided, a high default timeout of 300000 (5 minutes) is being set, which would still prevent indefinitely blocking clients.
This looks like a good idea to me, although I think unnecessary if heartbeats or TCP Keep Alive is enabled. Since heartbeats are enabled by default, I would change the default post-connection timeout to 0, but still support it as an option. Thoughts @hardcodet, @kibertoad?