Connections to MySQL servers can automatically time-out according to the
configured within the MySQL server.
To prevent these connections being automatically closed, the connector
can be configured to keep the connection alive by submitting a simple
SELECT statement (actually
SELECT 'KEEP_ALIVE') periodically
to ensure that the MySQL timeout is not reached and the connection
Two parameters configure the keepalive functionality:
The interval used to check for idle connections. If set to a value of 0, the keep alive check is disabled. Any value greater than zero is the interval check period in seconds.
The keep-alive statement is submitted if the time since the last activity reaches this timeout value.
The default setting for both parameters is
When set to
default, the values are automatically calculated by the connector
computing suitable values based on the
configured in the MySQL server.
connection.keepAlive.interval = (int) Math.floor(wait_timeout * 0.10); connection.keepAlive.timeout = (int) Math.floor(wait_timeout * 0.7);
tpm update alpha --property=connection.keepAlive.interval=30
Please note that Connector Keepalive is not compatible with Bridge mode.
In Bridge mode, the client session is directly connected to the MySQL server at the TCP level, literally forwarding the client's packet to the server. This means that closing connections is the responsibility of the MySQL server based on the configured wait_timeout value, not the Connector.