Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit b13b1eb5d2.

Reconnecting a MySQL connection

After you close a connection or an error has occurred, and if its underlying Stream supports it, you can re-open an existing connection. This is the case for tcp_connection and unix_connection.

[Warning] Warning

Unfortunately, boost::asio::ssl::stream does not support reconnection. If you are using tcp_ssl_connection and you close the connection or encounter an error, you will have to destroy and re-create the connection object.

If you are using tcp_connection or unix_connection, or any other stream supporting reconnection:

If your Stream type doesn't fulfill the SocketStream type requirements, then you can't use connection::connect or connection::close, and you are thus responsible for establishing the physical connection and closing the underlying stream, if necessary. Some guidelines:

Note that Boost.MySQL does not perform any built-in retry strategy, as different use cases have different requirements. You can implement it as you best like with these tools. If you implemented your own and you would like to contribute it, please create a PR in the GitHub repository.