[CSHARP-1298] Mongo DB Connection Issue - " MongoDB.Driver.MongoConnectionException: Unable to connect in the specified timeframe of '00:00:30' " Created: 27/May/15 Updated: 16/Nov/21 Resolved: 17/Jun/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Connectivity |
| Affects Version/s: | 1.10 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Ankur Jasoria | Assignee: | Craig Wilson |
| Resolution: | Done | Votes: | 0 |
| Labels: | query, question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Visual Studio on Windows7 |
||
| Description |
|
Can Any body help me how to make connection string for MongoDB if conditional are as follows- |
| Comments |
| Comment by Raju [X] [ 01/Feb/17 ] |
|
I am not able to connect to mongodb using connect-mdbc from powershell. |
| Comment by Craig Wilson [ 15/Nov/16 ] |
|
It was related to not being specific enough in the connection string. For instance, if you are talking to a replica set, you should specify the the replica set name in the connection string. |
| Comment by Amit Kumar [ 15/Nov/16 ] |
|
Getting the same error with mongo driver version: 1.10.0.62 The issue seems closed so what was the resolution ? |
| Comment by Mikhail Vaganov [X] [ 20/Oct/15 ] |
|
Thank you, Craig! It works very well! |
| Comment by Craig Wilson [ 16/Oct/15 ] |
|
Absolutely... Let me know if that fixes the issue. |
| Comment by Mikhail Vaganov [X] [ 16/Oct/15 ] |
|
Thank you for your answer, Craig! I'll test it. We have a replica set in our system. Like this: var credential = MongoCredential.CreateMongoCRCredential(_dataBaseName, _login, _password); , |
| Comment by Craig Wilson [ 16/Oct/15 ] |
|
Hi Mikhail, Since the problem seems to be around the DiscoveringMongoServerProxy, you can completely avoid this by telling us in the connection string what type of mongo cluster you are connecting to. For instance, if you are connecting to a replica set, provide the replica set name in the connection string: replicaSet=mySetName. If you are connecting to a shard router, provide the option connect=ShardRouter in the connection string. I'm not saying we don't have a bug here, but this should work around your problem for the time being. Craig |
| Comment by Mikhail Vaganov [X] [ 16/Oct/15 ] |
|
We have the same issue. The interesting thing is that sometimes we have this exception: MongoDB.Driver.MongoConnectionException: Unable to connect to server 192.168.100.101:27017: No connection could be made because the target machine actively refused it 192.168.100.101:27017. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 192.168.100.101:27017 But sometimes this: MongoDB.Driver.MongoConnectionException: Unable to connect in the specified timeframe of '00:00:30'. We found this exceptions during testing the case, when MongoDB starts after our application. There are two possible ways further: if we have the first type exception, then after starting of Mongo our Application can successfully connect to MongoDB: if we face with the second type exception, then the the Application cannot connect to MongoDB even after Mongo started, |
| Comment by Rami stern [ 28/May/15 ] |
|
The same issue happend to us as well using driver version 1.10.0.62. |
| Comment by Craig Wilson [ 27/May/15 ] |
|
Thanks Ankur. I'm having a hard time reconciling your stack trace with the 2.0 driver. Would you mind taking a screenshot of the properties window of the MongoDB.Driver.dll? 1. Find the MongoDB.Driver.dll on your system. The product version and file version on that tab should include the version of the driver your using. Thanks, |
| Comment by Ankur Jasoria [ 27/May/15 ] |
|
Craig, We are working on updated one. Thanks |
| Comment by Craig Wilson [ 27/May/15 ] |
|
Ankur, In the AffectsVersion property, you have used 2.0. This stack trace is from a previous version of the driver. Could you please confirm what version of the driver you are using? Thanks, |
| Comment by Ankur Jasoria [ 27/May/15 ] |
|
Hi Craig, Thanks for your quick reply !! Exception: MongoDB.Driver.MongoConnectionException: Unable to connect in the specified timeframe of '00:00:30'. I have also figure out on these issue and here authentication working fine. At my end I am working at server end to figure out the issue if any issue at server end ? If issue at code part end or MongoDB Driver end please figure out. Thanks. |
| Comment by Craig Wilson [ 27/May/15 ] |
|
Hi Ankur, Sorry you are having some trouble. Your connection string looks fine, but obviously there is a problem connecting to your servers. 1. There should be a lot more information in that exception than you are providing. Could you confirm that and, if so, please provide the entire stack trace? 2. The PLAIN mechanism is for using LDAP. I assume this is all setup and what you are wanting. Chances are that there is an authentication problem, and having the more full stack trace from (1) should help us identify that. Thanks, |