"Attempted to read past the end of the stream" when authentication enabled

500 views
Skip to first unread message

Senor Cardgage

unread,
Feb 21, 2012, 12:24:29 PM2/21/12
to mongodb-csharp
When I enable authentication, I get the error "Attempted to read past
the end of the stream"

Here is the command line I use to register the mongo service:
"C:\mongo\bin\mongod" --reinstall --auth --dbpath "c:\mongo\data\db" --
logpath "c:\mongo\logs" --profile=2

here is my connection string:

"mongodb://admin:adminpass@localhost"

Everything works properly when "--admin" is excluded from the command
line and "mongodb://localhost" is used for the connection string.

Robert Stam

unread,
Feb 21, 2012, 12:36:56 PM2/21/12
to mongodb...@googlegroups.com
Not sure where you are seeing this error. Can you provide a full stack trace?

Senor Cardgage

unread,
Feb 21, 2012, 12:40:28 PM2/21/12
to mongodb-csharp
at MongoDB.Driver.Internal.DirectConnector.Connect(TimeSpan
timeout) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal
\DirectConnector.cs:line 64
at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout,
ConnectWaitFor waitFor) in C:\work\10gen\mongodb\mongo-csharp-driver
\Driver\Core\MongoServer.cs:line 526
at MongoDB.Driver.MongoServer.Connect(ConnectWaitFor waitFor) in C:
\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoServer.cs:line 494
at MongoDB.Driver.MongoServer.ChooseServerInstance(Boolean slaveOk)
in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoServer.cs:line 1138
at MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase
database, Boolean slaveOk) in C:\work\10gen\mongodb\mongo-csharp-driver
\Driver\Core\MongoServer.cs:line 1051
at MongoDB.Driver.MongoCursorEnumerator`1.AcquireConnection() in C:
\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoCursorEnumerator.cs:line 184
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in C:\work
\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoCursorEnumerator.cs:line 194
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in C:\work
\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoCursorEnumerator.cs:line 126
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1
source)
at MongoDB.Driver.MongoCollection.FindOneAs[TDocument](IMongoQuery
query) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoCollection.cs:line 498
at MongoDB.Driver.MongoCollection`1.FindOne(IMongoQuery query) in C:
\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoCollection.cs:line 1639
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type
commandResultType, IMongoCommand command) in C:\work\10gen\mongodb
\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 891
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type
commandResultType, String commandName) in C:\work\10gen\mongodb\mongo-
csharp-driver\Driver\Core\MongoDatabase.cs:line 920
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](String
commandName) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoDatabase.cs:line 878
at MongoDB.Driver.MongoDatabase.RunCommand(String commandName) in C:
\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoDatabase.cs:line 854
at MongoDB.Driver.MongoServer.GetDatabaseNames() in C:\work\10gen
\mongodb\mongo-csharp-driver\Driver\Core\MongoServer.cs:line 823
at MongoDB.Driver.MongoServer.DatabaseExists(String databaseName)
in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core
\MongoServer.cs:line 615


On Feb 21, 10:36 am, Robert Stam <rob...@10gen.com> wrote:
> Not sure where you are seeing this error. Can you provide a full stack
> trace?
>

Senor Cardgage

unread,
Feb 21, 2012, 2:06:10 PM2/21/12
to mongodb-csharp
Here is a function that replicates the issue:

private void checkCollection(string un, string pw, string
dbName, string collectionName)
{
string cs = string.Format("mongodb://{0}:{1}@localhost:
27017/{2}", un, pw, dbName);
MongoServer srv = MongoServer.Create(cs);
try
{
srv[dbName].CollectionExists(collectionName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);

Senor Cardgage

unread,
Feb 21, 2012, 5:44:19 PM2/21/12
to mongodb-csharp
If I use my ip address in the connection string like this, for
example:

"mongodb://admin(admin):admi...@77.201.199.87"

the connection works properly, but if I use "localhost" or "127.0.0.1"
like this:

"mongodb://admin(admin):adminpass@localhost"

then it fails

Robert Stam

unread,
Feb 21, 2012, 6:11:22 PM2/21/12
to mongodb...@googlegroups.com
I'm about to be offline for the next 48 hours, but one of my colleagues will take a look at this.

sridhar

unread,
Feb 21, 2012, 8:29:21 PM2/21/12
to mongodb-csharp
What version of MongoDB and the driver you are using here?

On Feb 21, 3:11 pm, Robert Stam <rob...@10gen.com> wrote:
> I'm about to be offline for the next 48 hours, but one of my colleagues
> will take a look at this.
>
> On Tue, Feb 21, 2012 at 4:44 PM, Senor Cardgage <combolati...@gmail.com>wrote:
>
>
>
>
>
>
>
> > If I use my ip address in the connection string like this, for
> > example:
>
> > "mongodb://admin(admin):adminp...@77.201.199.87"

sridhar

unread,
Feb 21, 2012, 8:54:19 PM2/21/12
to mongodb-csharp
Seems to be the --profile 2 which is the problem. You can reproduce
even without the service code by just running the server from the
command shell with the profile level set to 2. For now my
recommendation is not to set the profiling level on the command line
to 2. I am going to open a JIRA ticket for this.

sridhar

unread,
Feb 21, 2012, 9:07:47 PM2/21/12
to mongodb-csharp
logged SERVER-5033 for this

On Feb 21, 5:29 pm, sridhar <srid...@10gen.com> wrote:
Reply all
Reply to author
Forward
0 new messages