I am using MySQL in tandem with nanomsg in my C application. nanomsg is creating some tcp connections to remote servers, while MySQL is connecting to a localhost database.
I am porting from SQLite, and don't have as much experience with MySQL, so please excuse me if this is trivial.
MySQL seems to work fine, creating the db on init. and inserting some records. However, when I start the tcp connection on nanomsg, I get:
Lost connection to MySQL server during query
MySQL server has gone away
If I don't create the thread that polls my remote tcp connection, it still does this. This is what is causing MySQL to lose its connection:
const char *endpoint = "tcp://xx.xxx.xxx.xx:3000";
int timeout = 5;
int sock = nn_socket (AF_SP, NN_PAIR);
assert (sock >= 0);
assert (nn_connect (sock, endpoint) >= 0);
assert (nn_setsockopt (sock, NN_SOL_SOCKET, NN_RCVTIMEO, &to, sizeof (to)) >= 0);
assert (nn_setsockopt (sock, NN_SOL_SOCKET, NN_SNDTIMEO, &to, sizeof (to)) >= 0);
I tried to raise the read timeout in MySQL, but it didn't work.
int MYSQlTimeout = 6000;
mysql_options(mysqldb,MYSQL_OPT_READ_TIMEOUT,&MYSQlTimeout);
I also tried adding mysqld to /etc/hosts.allow mysqld: 127.0.0.1
Still doesn't work.
Any help would be greatly appreciated.