Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling MongoDB disconnect/reconnects from Node
    text
    copied!<p>When my MongoDB connection is idle for a few minutes, the next request ends in error. From the <code>mongo</code> command line client, it looks like this:</p> <pre><code>&gt; db.users.find() Sat Jan 12 23:42:35 Socket recv() errno:54 Connection reset by peer 107.22.25.25:47207 Sat Jan 12 23:42:35 SocketException: remote: 107.22.25.25:47207 error: 9001 socket exception [1] server [107.22.25.25:47207] Sat Jan 12 23:42:35 DBClientCursor::init call() failed Sat Jan 12 23:42:35 query failed : chowology.users {} to: ds047207.mongolab.com:47207 Error: error doing query: failed Sat Jan 12 23:42:35 trying reconnect to ds047207.mongolab.com:47207 Sat Jan 12 23:42:35 reconnect ds047207.mongolab.com:47207 ok </code></pre> <p>I see the problem against sandbox instances of MongoHQ and MongoLab.</p> <p>The next request goes through fine, because of the reconnect. This is a problem in my web app, because after a few minutes of inactivity, this error will come up during a web request. There are two things that surprise me:</p> <ol> <li>That MongoDB connections are destroyed so regularly and frequently, and</li> <li>That the driver simply raises an exception as opposed to automatically retrying after reconnecting (I'm using connect-mongo which uses mongoose which, in turn, uses <a href="https://github.com/mongodb/node-mongodb-native" rel="nofollow">node-mongodb-native</a>).</li> </ol> <p>Is this everyone else's experience? How is this supposed to be handled? I'd be surprised if app developers wrap their database operations in some retry-exception-handling nonsense.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload