2

I'm building a webapp with MongoDB/PHP, and everything's going great... except one thing.

My database connection is flaky. After X amount of time, when I refresh the page I get errors because queries are failing. I check mongod.exe and what I see is "Connection accepted from 127.0.0.1" - then I go back, refresh again, and everything's running all well and good.

What could be causing this? Database connectivity issues are something I never had to deal with in MySQL - but that's a whole different beast.

Community
  • 1
  • 1
Kavi Siegel
  • 2,964
  • 2
  • 24
  • 33
  • What OS are you running on? How are you connecting to mongo from php? – Leopd Oct 01 '11 at 15:53
  • 1
    I'm on Windows 7 64 bit. Connecting like so now: `try{ $this->db = new Mongo(); }catch(MongoConnectionException $e){ die('Mongo could not connect.'); }` Before it was just `$this->db = new Mongo();` – Kavi Siegel Oct 02 '11 at 01:34
  • Is it "couldn't send query: No error" error ? If yes, please check here ( https://groups.google.com/group/mongodb-user/browse_thread/thread/71aa93e01dfd7f65/a67fae24cbe4cc1c ) . And check you have last updated driver. – Aurélien B Oct 07 '11 at 07:49
  • I received this again today, and I did a little more research. As far as I can see, a lot of Mongo users are getting this. My extension was more current than the one on Mongo's Github, somehow, so I looked elsewhere for newer versions. I downloaded from the php.net page "PHP 5.3 VC9 Thread-Safe Mongo extension," which is more current than the github and my former installation. I'm hoping this solves it. I'll keep this thread updated. Thanks! – Kavi Siegel Oct 27 '11 at 16:11

1 Answers1

1

I would highly recommend you do your development with mongodb in a unix environment as they update the code the most often and you won't have to worry about strange bugs. Long ago i decided that doing dev in windows was much too inconvenient and moved my work environment to linux. If this sounds daunting, you might look into running a virtual machine with a local mount via samba such that you can run directly on a linux server on your local machine. Then you will have an environment similar to your production env. Hope this is helpful.

krob
  • 103
  • 1
  • 5