SA-MP Forums Archive
(Error ID: 2006, MySQL server has gone away) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: (Error ID: 2006, MySQL server has gone away) (/showthread.php?tid=149198)



(Error ID: 2006, MySQL server has gone away) - cAMo - 21.05.2010

Quote:

(Error ID: 2006, MySQL server has gone away)

I login to my server and MySQL works properly. If I leave my server set for 24 hours (or extended time), MySQL comes back with an error and says that the connection is dead.

Why is this happening? How do I keep the connection/reestablish it?


Re: (Error ID: 2006, MySQL server has gone away) - BLAbla93 - 21.05.2010

refresh the connection


Re: (Error ID: 2006, MySQL server has gone away) - cAMo - 21.05.2010

How?

How often do you need to?

Suggestions?


Re: (Error ID: 2006, MySQL server has gone away) - cAMo - 21.05.2010

Anyone?


Re: (Error ID: 2006, MySQL server has gone away) - Anwix - 21.05.2010

A quick way would be to set a timer that checks the connection of the mysql every 5-10minutes.

pawn Code:
forward CheckMySQL();
public CheckMySQL()
{
   if (!mysql_ping())
   {
     mysql_connect(host, user, database, pass);
   }
}



Re: (Error ID: 2006, MySQL server has gone away) - cAMo - 21.05.2010

mysql_reconnect?


Re: (Error ID: 2006, MySQL server has gone away) - WackoX - 21.05.2010

pawn Code:
forward CheckMySQL();
public CheckMySQL()
{
   if (!mysql_ping())
   {
     mysql_connect(host, user, database, pass);
   }
}
So that means put CheckMySQL(); on top of all functions which contains queries.


Re: (Error ID: 2006, MySQL server has gone away) - cAMo - 21.05.2010

Why not reconnect though?


Re: (Error ID: 2006, MySQL server has gone away) - Sergei - 21.05.2010

@WackoX, if you know nothing about that plugin please DO NOT suggest stupid things. CheckMySQL() or other idiotic functions were using in the era of Adrenaline's plugin. I thought we have already gone over that.

@cAMo, this is in no way scripting discussion, so keep it in plugin's topic and not on two different places.