简体   繁体   中英

Mongodb autoConnectRetry option in connection string is not working with C# driver

I have a quick questions here. I am using mongodb with C# and Java. Connectionstring that i use is:

mongodb.domain.com/?autoConnectRetry=true

The same connection string is working with Java but not with C#. I saw many posts around this that, if we remove autoConnectRetry option it works fine.

Looked at the logs and saw that its erroring out with below exception

System.ArgumentException: Invalid option 'autoConnectRetry'.
Parameter name: url
   at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
   at MongoDB.Driver.MongoUrl..ctor(String url)
   at MongoDB.Driver.MongoUrl.Create(String url)
   at MongoDB.Driver.MongoServer.Create(String connectionString)

Is there any alternative that can make this work?

I am using .NET Framework 3.5 and Mongodb C# driver v 1.0

There is just no such option ("autoConnectRetry") in C# MongoDb driver, while there is in Java, so you will have to implement retry logic yourself. If you just want to use the same connection string for both and don't care about retry logic - I think that in current version of the driver it no longer throws InvalidOperationException on unknown options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM