tencent cloud

TencentDB for MongoDB

Release Notes and Announcements
Release Notes
Announcements
User Guide
Product Introduction
Overview
Strengths
Use Cases
Cluster Architecture
Product Specifications
Features
Regions and AZs
Terms
Service Regions and Service Providers
Purchase Guide
Billing Overview
MongoDB Pricing
Billing Formula
Payment Overdue
Backup Space Billing
Configuration Adjustment Billing
Getting Started
Quickly Creating an Instance
Connecting to a TencentDB for MongoDB Instance
Reading/Writing Database
Operation Guide
Access Management
Instance Management
Node Management
Version Upgrade
Network Configuration
Monitoring
Backup and Rollback
Database Audit
Data Security
SSL Authentication
Log Management
Database Management
Multi-AZ Deployment
Disaster Recovery/Read-Only Instances
Parameter Configuration
Recycle Bin
Task Management
Performance Optimization
Data Migration Guide
Practical Tutorial
Optimizing Indexes to Break Through Read/Write Performance Bottlenecks
Troubleshooting Mongos Load Imbalance in Sharded Cluster
Considerations for Using Shard Clusters
Sample of Reading and Writing Data in MongoDB Instance
Methods for Importing and Exporting Data Based on CVM Connected with MongoDB
What to Do for Errors of Repeated Instance Creation and Deletion of Databases with the Same Names?
Troubleshooting MongoDB Connection Failures
Shard Removal Task: Guide for Confirming the Progress and Troubleshooting Issues
Performance Fine-Tuning
Ops and Development Guide
Development Specifications
Command Support in Sharded Cluster v3.2
Command Support in v3.6
Development Ops
Troubleshooting
Increased Slow Queries
Number of Connections Exceeding Limit
API Documentation
History
Introduction
API Category
Making API Requests
Instance APIs
Backup APIs
Account APIs
Other APIs
Task APIs
Introduction
Data Types
Error Codes
Instance Connection
Shell Connection Sample
PHP Connection Sample
Node.js Connection Sample
Java Connection Sample
Python Connection Sample
Python Read/Write Sample
Go Connection Sample
PHP Reconnection Sample
Product Performance
Test Environment
Test Method
Test Result
FAQs
Cost
Features
Sharded Cluster
Instance
Rollback and Backup
Connection
Data Migration
Others
Service Agreement
Service Level Agreement
Terms of Service
Glossary
Contact Us

Connection

PDF
Focus Mode
Font Size
Last updated: 2025-10-20 14:59:04

What should I do in case of disconnection from TencentDB for MongoDB?

See Connecting to TencentDB for MongoDB Instance to eliminate authentication issues.

What should I do if the message "Remote server has closed the connection" is displayed in TencentDB for MongoDB?

First, see Connecting to TencentDB for MongoDB Instance to eliminate authentication issues. If you can connect to MongoDB but still encounter this problem, you may need a reconnection mechanism. For more information, see PHP Reconnection Sample.

WiredTiger 3.2 has the problem of table lock. Is TencentDB for MongoDB affected by the same issue?

It depends on the specific situation. For example, a global lock is required to create indexes by default, and a lock is also needed when you execute the fsynclock command. Lock is a feature of databases, and is used to deal with the problems of concurrent access. Generally, a lock is required, as long as it does not affect the operation of your business.

Which version of the driver should be used in MongoDB?

We recommend that you use the latest version, for example, mongo-1.6 or later for PHP.

Which programming languages can be used to connect to MongoDB?

TencentDB for MongoDB can be connected by using a variety of programming languages, such as Shell, PHP, Node.js, Java, and Python. For more information, see Connecting to TencentDB for MongoDB Instance.

Which programming language clients are supported by TencentDB for MongoDB?

TencentDB for MongoDB provides the same compatibility as MongoDB. TencentDB for MongoDB supports any client that is supported by the official MongoDB. For example: C, C++, C#, Java, Node.js, Python, PHP, and Perl. For more information, see Start Developing with MongoDB.

How do I connect to TencentDB for MongoDB in shell?

For more information, see Shell Connection Sample.

What URIs in service applications can be used to connect to MongoDB?

What should I do if I cannot connect to TencentDB for MongoDB using meteor and other types of frameworks and class libraries?

This is usually caused by incorrect connection method or URI. Check and verify the cause first.

How do I set the maximum number of connections to MongoDB in PHP?

MongoDB driver can control the number of connections by configuring the maxPoolSize parameter in the URL connection.
In the MongoDB driver, you can set the connection count through the Mongo::setPoolSize() method.

What is the limit on the number of connections to MongoDB?

For more information, see Product Specifications.

How do I reconnect to MongoDB manually?

Instead of simply allowing you to access mongod, TencentDB for MongoDB database service provides a load balancer IP for access. You can use this IP to connect to a range of route access layers similar to mongos. The client driver establishes a persistent connection with an access server using a load balancer IP. If the connection is active for a long period of time, Tencent Cloud will not impose an intervention on this status. However, if the persistent connection is inactive for more than one day (this period will be adjusted with optimized version), the route access layer will terminate the connection. Generally, the client driver will implement an automatic reconnection. However, this process cannot be implemented by some language drivers. For the language drivers that cannot implement automatic reconnection, if you attempt to communicate with the TencentDB for MongoDB service using a terminated connection, an error message such as "Remote server has closed the connection" will be returned. So manual reconnection is required. Here is a demo for PHP reconnection.
Reconnection based on PHP mongo driver


How do I use mongoose to connect to TencentDB for MongoDB?

Here are the parameters for mongoose to connect to TencentDB for MongoDB:
var dbUri = " mongodb:// " + user + " : " +password + " @ " +host + ":" +port + " / " + dbName;

var opts = {
  auth: {
    authMechanism : ' MONDODB-CR'
}
var connection = mongodb.createConnection(dbUri, opts);

Can I connect to MongoDB from a public network?

Indeed, for detailed procedures, please refer to Enabling External Access.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback