C# driver exceptions

238 views
Skip to first unread message

Gino

unread,
Feb 12, 2012, 5:11:49 AM2/12/12
to mongodb-user
Hi,

it seems to me that the c# driver is throwing exceptions around
internally when auth is enabled. When i turn on breaking on all thrown
CLR exceptions in VS. I keep getting the following:

MongoCommandException

Command 'buildinfo' failed: need login { response: { "errmsg" : "need
to login", "ok" : 0.0 }}

stack:

MongoDB.Driver.DLL!
MongoDB.Driver.Internal.MongoConnection.RunCommand(string
collectionName, MongoDB.Driver.QueryFlags queryFlags,
MongoDB.Driver.CommandDocument command) Line 363 C#
MongoDB.Driver.DLL!
MongoDB.Driver.MongoServerInstance.VerifyState(MongoDB.Driver.Internal.MongoConnection
connection) Line 384 + 0x2d bytes C#
MongoDB.Driver.DLL!MongoDB.Driver.MongoServerInstance.VerifyState()
Line 226 + 0x10 bytes C#
> MongoDB.Driver.DLL!MongoDB.Driver.Internal.MongoConnectionPool.TimerCallback(object state) Line 284 + 0x28 bytes C#



If i only catch uncaught exceptions, everything is fine but i am just
wondering if i am tacking a performance hit as throwing exceptions is
expensive and the driver seems to be doing that internally non-stop

Thanks
Gino

Robert Stam

unread,
Feb 12, 2012, 9:37:01 AM2/12/12
to mongod...@googlegroups.com
You are right, this is very annoying.

The history behind this is that the server didn't used to require authentication for the buildInfo command. At one point the server was changed to require authentication for the buildInfo command, which caused several drivers to break when authentication was on, including the C# driver. The initial workaround for this in the C# driver was to catch the exception and ignore it, but as you have noticed, this is rather annoying when you have Visual Studio configured to break when any exception is thrown.

One option for you is to upgrade the server to 2.0.2. The server has been changed back to no longer require authentication for the buildInfo command, so upgrading to 2.0.2 is one way to stop seeing these internal exceptions.

Also, Alexander Nagy contributed a nice patch which modifies the C# driver to eliminate cases where the driver catches and either ignores or rethrows the exceptions. This change will be in the upcoming 1.4 version of the C# driver, and once it is released that also will make the driver friendlier to use in the case where you have configured Visual Studio to break when any exception is thrown.

Gino

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Gino

unread,
Feb 12, 2012, 4:01:37 PM2/12/12
to mongodb-user
ahh works fine with 2.0.2

is that something that's going to come back in the future? What's
build info? version if the server etc?

Robert Stam

unread,
Feb 12, 2012, 4:38:02 PM2/12/12
to mongod...@googlegroups.com
The buildInfo command returns information about what version of the server you are connected to.

Many of the drivers call the buildInfo command while connecting.

I don't think the server will change back to require authentication for the buildInfo command, but even if it does once version 1.4 of the C# driver is out the C# driver would handle that situation without an exception being thrown.
Reply all
Reply to author
Forward
0 new messages