Sudden “MySQL server has gone away” error in PHP site

前端 未结 4 1168
抹茶落季
抹茶落季 2020-12-09 17:57

Today one of my websites started showing

Error Number: 2006
MySQL server has gone away

It\'s a low-traffic client site running under Apache 2.2.9 (Debian

4条回答
  •  离开以前
    2020-12-09 18:47

    As I said in my update, I concluded that the problem with MySQL arises when the link to Facebook takes longer than the maximum connection time with the DB. None of the suggestions could beat this limitation, so I decided to work around it and reconnect every time I presumed the link maybe gone.

    So after each call to Facebook, I used to following code:

    $this->load->database();
    $this->db->reconnect();

    This is the particular solution when using CodeIgniter, and AFAIK the db->reconnect() function is only available since version 1.7.2 so I updated it in order to work.

    Thanks everyone for your answers!

提交回复
热议问题