Sails server:
MongoDB server:
I can successfully lift Sails, connect the datastore, and use the models without any problem.
However, this test will result on a timeout:
let mongo = require('mongodb');
let uri = 'mongodb://' + process.env.MONGO_SERVER + ':' + process.env.MONGO_PORT + '/sails';
mongo.MongoClient.connect(uri, function(err, db) {
if(err){
return res.serverError(err);
}
return res.json("open");
});
{ MongoError: failed to connect to server [192.168.99.2:27027] on first connect [MongoError: connect ETIMEDOUT 192.168.99.2:27027]
at Pool.<anonymous> (....\node_modules\mongodb-core\lib\topologies\server.js:329:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (....\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Connection.g (events.js:291:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (....\node_modules\mongodb-core\lib\connection\connection.js:187:49)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
name: 'MongoError',
message: 'failed to connect to server [192.168.99.2:27027] on first connect [MongoError: connect ETIMEDOUT 192.168.99.2:27027]' }
I am using the exact same server information used on the datastore.
So what could be wrong here?
And as important: is it possible to use the global Sails connection pool instead of creating a new connection? How? I have searched the documentation but cannot find specific references.
Code was wrong -- using port 27027, while it should be 27017.
Datastore connection worked because of a correct fallback I didn't notice