问题
I'm working with cppcms framework with cppdb and mysql and got "Lost connection to MySQL server during query" error when trying to make a query on a remote database.
I also have the same database locally, and the app works ok with that one.
Remote mysql version: mysqld Ver 5.5.29-0ubuntu0.12.10.1 for debian-linux-gnu on i686 ((Ubuntu))
Thanks for your help
回答1:
Two questions:
- Do you use connection pooling?
- Do you destroy
cppdb::session
object when you done using it or you are keeping it active all the time?
If you keep cppdb::session
all the time you probably not need to do it because MySQL closes idle connections after certain time period. It is better to use connection pooling provided by CppDB.
If you are already using connection pooling try to change the @pool_max_idle
parameter to smaller value.
See: http://cppcms.com/sql/cppdb/connstr.html#speckeys for more details
来源:https://stackoverflow.com/questions/15102878/lost-connection-to-mysql-server-during-query-on-remote-host