This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destroy connection on socket timeout due to newer node versions not c…
…losing the socket. Updated version to 2.0.6
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var Server = require('./lib/topologies/server'); | ||
|
||
// Attempt to connect | ||
var server = new Server({ | ||
host: 'localhost', port: 27017, socketTimeout: 500 | ||
}); | ||
|
||
// function executeCursors(_server, cb) { | ||
// var count = 100; | ||
// | ||
// for(var i = 0; i < 100; i++) { | ||
// // Execute the write | ||
// var cursor = _server.cursor('test.test', { | ||
// find: 'test.test' | ||
// , query: {a:1} | ||
// }, {readPreference: new ReadPreference('secondary')}); | ||
// | ||
// // Get the first document | ||
// cursor.next(function(err, doc) { | ||
// count = count - 1; | ||
// if(err) console.dir(err) | ||
// if(count == 0) return cb(); | ||
// }); | ||
// } | ||
// } | ||
|
||
server.on('connect', function(_server) { | ||
|
||
setInterval(function() { | ||
_server.insert('test.test', [{a:1}], function(err, r) { | ||
console.log("insert") | ||
}); | ||
}, 1000) | ||
// console.log("---------------------------------- 0") | ||
// // Attempt authentication | ||
// _server.auth('scram-sha-1', 'admin', 'root', 'root', function(err, r) { | ||
// console.log("---------------------------------- 1") | ||
// // console.dir(err) | ||
// // console.dir(r) | ||
// | ||
// _server.insert('test.test', [{a:1}], function(err, r) { | ||
// console.log("---------------------------------- 2") | ||
// console.dir(err) | ||
// if(r)console.dir(r.result) | ||
// var name = null; | ||
// | ||
// _server.on('joined', function(_t, _server) { | ||
// if(name == _server.name) { | ||
// console.log("=========== joined :: " + _t + " :: " + _server.name) | ||
// executeCursors(_server, function() { | ||
// }); | ||
// } | ||
// }) | ||
// | ||
// // var s = _server.s.replicaSetState.secondaries[0]; | ||
// // s.destroy({emitClose:true}); | ||
// executeCursors(_server, function() { | ||
// console.log("============== 0") | ||
// // Attempt to force a server reconnect | ||
// var s = _server.s.replicaSetState.secondaries[0]; | ||
// name = s.name; | ||
// s.destroy({emitClose:true}); | ||
// // console.log("============== 1") | ||
// | ||
// // _server.destroy(); | ||
// // test.done(); | ||
// }); | ||
// }); | ||
// }); | ||
}); | ||
|
||
server.connect(); |