Error
MongoServerSelectionError: connection timed out
at Timeout._onTimeout (D:\NodeJS\SearchEngine\node_modules\mongodb\lib\core\sdam\topology.js:438:30)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
reason: TopologyDescription {
type: 'Unknown',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
Code
try {
const client = await MongoClient.connect(connection.url, usermail.config_connection)
var header = [];
const db = client.db(connection.name);
console.log(header_data.return_call_back_header(header_data.header_id_info.ecommerce));
// res.render('index.ejs', { title: header });
console.log(header);
} catch (error) {
console.error(error)
}
Config connection
const config_connection = {
connectTimeoutMS: 5000,
socketTimeoutMS: 5000,
useUnifiedTopology: true,
useNewUrlParser: true,
serverSelectionTimeoutMS: 5000,
}
URL
url:'mongodb://localhost:27017/searchEngine', name:'searchEngine',