90% of the times databse connection errors on mac

keshav00014127

New Member
YetiShare User
Jul 21, 2014
5
0
0
Hello,

Around 90% of time, when a friend is trying to download files from his mac(150mbps connection), these database errors are occuring. We are getting the database connection failed errors. And if at the same time I try to connect, it's working on my end, and files also download. And when he refresh page again after sometime. It goes fine!

Error log is getting filled with these errors, and that's when we are not getting traffic on our site, and is being tested by us only..

in error_log, there are 291 instances from 15th august (2 days after we had put it live):-

[29-Aug-2014 03:00:46 America/Denver] Failed connecting to the database with the supplied connection details. Please check the details are correct and your MySQL user has permissions to access this database.<br/><br/>(host: localhost, user: downlop7_gsi, pass: ********)

[29-Aug-2014 03:00:46 America/Denver] PHP Fatal error: Call to a member function prepare() on a non-object in /home2/downlop7/public_html/gsinfinite/includes/class.database.php on line 124

[29-Aug-2014 03:00:46 America/Denver] Failed connecting to the database with the supplied connection details. Please check the details are correct and your MySQL user has permissions to access this database.<br/><br/>(host: localhost, user: downlop7_gsi, pass: ********)

Please help with this
 

keshav00014127

New Member
YetiShare User
Jul 21, 2014
5
0
0
Thanks thefilebay, we are using a shared host (bluehost) because of their unlimited space, so cannot change max connections in mysql!
Today we turned off download tracker since then this problem now occurs, 10% of the times.

What will be the most cost effective way to run this site ? Is a digitalocean 1gb memory droplet enough ? or what should we go after ?
 

ollie

Member
YetiShare User
Apr 25, 2013
75
5
8
United Kingdom
Shared hosts with "Unlimited Space" do not allow file sharing sites most of the time. Ideally you want a dedicated server for it. You can probably get away with a 1GB VPS on digital ocean if you have not much traffic.
 

keshav00014127

New Member
YetiShare User
Jul 21, 2014
5
0
0
Thanks thefilebay, for your suggestions. But I was able to find the root of problem to be idle connections to database.
And now everything is working nicely!

There was just one line fix I implemented, which is:
in your includes\class.databse.php file in function close()

just add this line:
Code:
 public function close()
    {
        $this->result=null;
        self::closeDB();
    }
In research I found that result object, was not letting the database connections close, so they were timing out after 60 seconds. After the above code, I haven't faced any problem since.

May be Script creator can also add this in the code for all.