Does mongoDB have reconnect issues or am i doing it wrong?

后端 未结 6 1439
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 07:53

I\'m using nodejs and a mongoDB - and I\'m having some connection issues.

Well, actually \"wake\" issues! It connects perfectly well - is super fast and I\'m general

6条回答
  •  春和景丽
    2020-12-04 08:52

    Increasing timeouts may help.

    • "socketTimeoutMS" : How long a send or receive on a socket can take before timing out.
    • "wTimeoutMS" : It controls how many milliseconds the server waits for the write concern to be satisfied.
    • "connectTimeoutMS" : How long a connection can take to be opened before timing out in milliseconds.

      $m = new MongoClient("mongodb://127.0.0.1:27017", array("connect"=>TRUE, "connectTimeoutMS"=>10, "socketTimeoutMS"=>10, "wTimeoutMS"=>10));

          $db= $m->mydb;
          $coll = $db->testData;
          $coll->insert($paramArr);
      

提交回复
热议问题