@@ -187,17 +187,16 @@ MongoStore.prototype.initialise = function(resourceConfig) {
187187 if ( ! self . _config . url ) {
188188 return console . error ( "MongoDB url missing from configuration" ) ;
189189 }
190- //Set a keep alive timer.
191- timers . setTimeout ( self . keepAlive . bind ( self ) , KEEP_ALIVE_TIMER_MS ) ;
192190 self . resourceConfig = resourceConfig ;
193191 self . relationshipAttributeNames = MongoStore . _getRelationshipAttributeNames ( resourceConfig . attributes ) ;
194192 mongodb . MongoClient . connect ( self . _config . url , {
195- server : {
196- reconnectTries : 999999999 ,
197- reconnectInterval : 5000
198- }
193+ autoReconnect : true ,
194+ reconnectTries : 999999999 ,
195+ reconnectInterval : 5000
199196 } ) . then ( function ( db ) {
200197 self . _db = db ;
198+ //Set a keep alive timer.
199+ timers . setTimeout ( self . keepAlive . bind ( self ) , KEEP_ALIVE_TIMER_MS ) ;
201200 self . _db . on ( "timeout" , function ( ) {
202201 console . error ( "mongodb connection timeout." ) ;
203202 self . ready = false ;
@@ -210,9 +209,6 @@ MongoStore.prototype.initialise = function(resourceConfig) {
210209 } ) ;
211210 } ) . catch ( function ( err ) {
212211 console . error ( "mongodb connection failed:" , err . message ) ;
213- setTimeout ( function ( ) {
214- self . initialise ( resourceConfig ) ;
215- } , 5000 ) ;
216212 } ) . then ( function ( ) {
217213 var resourceName = resourceConfig . resource ;
218214 var collection = self . _db . collection ( resourceName ) ;
0 commit comments