No suitable servers found using mongoc connection to DataBase

15 ビュー (過去 30 日間)
Gerardo Moreno
Gerardo Moreno 2023 年 3 月 15 日
回答済み: Piyush Dubey 2023 年 5 月 30 日
I get an error when trying to start a connection to my database in MongoDB. I am using the code from the documentation:
server = "myIP";
port = 27017;
dbname = "myDBName";
conn = mongoc(server,port,dbname,UserName="user",Password="Pass");
The error I get is as follows: Error using database.mongo.connection
[Mongo Driver Error]: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout
calling ismaster on 'myIP:27017'].
Error in mongoc (line 52)
conn = database.mongo.connection(varargin{:});
Error in mongodb (line 4)
conn = mongoc(server,port,dbname);
I have already verified the connection in the MongoDB shell, I also tried to connect through Compass and in both cases I can connect with my credentials. I turned off the firewall and the error still appears, I hope someone can help me.

回答 (1 件)

Piyush Dubey
Piyush Dubey 2023 年 5 月 30 日
Hi Gerado,
[Mongo Driver Error] implicates the error is thrown by MongoDB and later sent towards MATLAB. The following documentation will help you troubleshoot different errors in MongoDB and the Database Toolbox Interface:
These will help you figure out the best practices to use the functionalities provided by the Toolbox to connect to MongoDB data base.
Additionally, this link should be helpful to resolve selection timeout errors in MongoDB:
Hope this helps!

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by