How the tcp connection is established and closed during the database call?
The below code is to get lists of databases in mongodb using mongoclient in nodejs
async function main(){
const uri = "mongodb+srv://<username>:<password>@<your-cluster-url>/test?retryWrites=true&w=majority";
const client = new MongoClient(uri);
try {
await client.connect();
await listDatabases(client);
} catch (e) {
console.error(e);
} finally {
await client.close();
}
}
main().catch(console.error);
1.Does the "await client.connect()" establish a tcp connection with mongoDb?
2.Does the "await client.close()"close a tcp connection with mongoDb?
3.How does the mongodb and nodejs communicate using tcp ?