Questions about node-postgres KeepAlive and keepAliveInitialDelayMillis
Hello,
I'm currently developing a PC application using your pg-node library. I'm trying to find documentation on keepAlive and keepAliveInitialDelayMillis but can't find anything that explains what these parameters do. Can you elaborate on what they do?
For example, does a pool connection use its own keepAlive protocol (different from the keepAlive postgres server protocol) if set to true? Does it periodically check with the server? Also, does keepAliveDelaymillis determine the duration between the periodic checks?
How do these parameters interact with the windows registry variables (KeepAliveTime and KeepAliveInterval)? Are your keepalive parameters affected by the registry keep alive variables?
Note: There is no documentation about these parameters at https://node-postgres.com/
From reading the code, it sets the keep alive property on the socket connection. This is a property on Nodejs net.Socket.
And from Microsoft:
When this socket option is enabled, the TCP stack sends keep-alive packets when no data or acknowledgement packets have been received for the connection within an interval. For more information on the keep-alive option, see section 4.2.3.6 on the Requirements for Internet Hosts—Communication Layers specified in RFC 1122 available at the IETF website. (This resource may only be available in English.)
the code:
- https://github.com/brianc/node-postgres/blob/2a8efbee09a284be12748ed3962bc9b816965e36/packages/pg/lib/connection.js#L46C1-L49C8
- https://github.com/brianc/node-postgres/blob/2a8efbee09a284be12748ed3962bc9b816965e36/packages/pg/lib/connection.js#L19C5-L24C39
- https://github.com/brianc/node-postgres/blob/2a8efbee09a284be12748ed3962bc9b816965e36/packages/pg/lib/stream.js#L5C1-L8C28