[CSHARP-168] inserts on an authenticated DB like mongoHQ.com with safemode=false do not work Created: 14/Feb/11  Updated: 20/Mar/14  Resolved: 15/Feb/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 0.11
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aditya Iyer Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows 7 client connecting to mongohq.com server



 Description   

inserts on an authenticated DB like mongoHQ.com with safemode=false do not work. works with safemode=true. I've tried with latest release and also with latest source from https://github.com/mongodb/mongo-csharp-driver.git with same results. Only information I could find on this on google is http://groups.google.com/group/mongodb-csharp/browse_thread/thread/401006010e7c6fe8 where some fix seems to have been applied. Was that applied to some other driver?



 Comments   
Comment by Robert Stam [ 15/Feb/11 ]

The way you are using the connection string is correct.

Please reopen the case if you figure out whether the failures you are seeing under your specific test environment are driver related.

Comment by Aditya Iyer [ 15/Feb/11 ]

Thanks for looking at this. I was actually trying to run unit tests in the Visual Studio 2010 IDE with the [TestMethod()] attribute and inserts to mongoHQ are exhibiting strange behavior, sometimes they succeed but most of the time no records get inserted. The same tests are inserting fine for a local instance of mongod and a LAN instance both authenticated and not.

When I ran inserts in a non-test application environment the inserts are going through fine to mongoHQ all the time.

No idea right now why the issue with running unit tests and that too only with mongoHQ.

I'm connecting in the following manner
MongoCollection<BsonDocument> mc = MongoDatabase.Create(connectionString).GetCollection(recoCollectionName);
Where
connectionString is like mongodb://<username>:<password>@flame.mongohq.com:27022/wsb
and then just an mc.Insert(...)

Of course since it works otherwise, that should not be a problem...

Comment by Robert Stam [ 14/Feb/11 ]

I created a test account at MongoHQ and my little test program works against MongoHQ just like it did locally. All I changed was the URL to point to MongoHQ and the credentials.

How are you setting the credentials? Perhaps the problem lies there.

Comment by Robert Stam [ 14/Feb/11 ]

I am unable to reproduce your authentication problem testing locally. Here's the code I'm using:

http://www.pastie.org/1562919

When using the proper credentials it works identically whether safemode=false or safemode=true.

With invalid credentials and safemode=true I get:

1. All operations throw an exception

With invalid credentials and safemode=false I get:

1. All the Inserts fail silently because they are fire and forget. The FindAll method throws an exception.

Can you make sure you are setting the proper credentials? If so let me know and I will open a MongoHQ account and test against it.

Thanks!

Comment by Aditya Iyer [ 14/Feb/11 ]

I'm not getting an exception, the data is simply not inserted. The data is inserted using mongo shell (I assume it uses safemode=false by default) so it doesn't seem to be an issue at mongohq side.

Comment by Robert Stam [ 14/Feb/11 ]

Can you define "do not work"? Are you getting an exception? Or is the data simply not inserted?

Turning safemode on shouldn't have anything to do with authentication...

The Google groups discussion you found is for a different driver.

Generated at Wed Feb 07 21:36:00 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.