amqplib icon indicating copy to clipboard operation
amqplib copied to clipboard

Introduce post-connection timeout setting

Open hardcodet opened this issue 6 years ago • 1 comments

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.

hardcodet avatar Jul 23 '19 16:07 hardcodet

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?

cressie176 avatar Jun 05 '22 13:06 cressie176