[CSHARP-928] System.IO.EndOfStreamException: Attempted to read past the end of the stream. Created: 11/Mar/14  Updated: 08/May/19  Resolved: 20/Jun/14

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

Type: Bug Priority: Major - P3
Reporter: Blake Niemyjski Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Microsoft Windows Server 2012 R2 Standard



 Description   

Since we are using the 1.9 driver we started noticing the following exception popup (11 occurrences). We have 2 occurrences of this happening with 1.8 but it seems to be happening a ton more with 1.9. I'm sorry I don't have a repro but I believe it had to do with passing hundreds of excludes into a not in condition (which we have fixed). But I figured I'd submit a bug for it just to bring it to your attention:

System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
at MongoDB.Driver.Operations.CommandOperation`1.Execute(MongoConnection connection)
at MongoDB.Driver.MongoCollection.RunCommandAs[TCommandResult](IMongoCommand command, IBsonSerializer resultSerializer, IBsonSerializationOptions resultSerializationOptions)
at MongoDB.Driver.MongoCollection.RunCommandAs[TCommandResult](IMongoCommand command)
at MongoDB.Driver.MongoCollection.Count(CountArgs args)



 Comments   
Comment by Roshni [ 08/May/19 ]

continuously getting this issue? can anyone help me regarding the solution?

 

MongoDB.Driver.MongoConnectionException
HResult=0x80131500
Message=An exception occurred while receiving a message from the server.
Source=MongoDB.Driver.Core
StackTrace:
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer()
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.PooledConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquiredConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](DatabaseNamespace databaseNamespace, BsonDocument command, IElementNameValidator commandValidator, Func`1 responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase.ExecuteProtocol(IChannelHandle channel, BsonDocument command, Func`1 responseHandling, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase.ExecuteBatch(IChannelHandle channel, BatchableSource`1 requestSource, Int32 originalIndex, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase.ExecuteBatches(IChannelHandle channel, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkUnmixedWriteOperationBase.Execute(IChannelHandle channel, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteUpdates(IChannelHandle channel, IEnumerable`1 requests, Boolean isLast, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.ExecuteBatch(IChannelHandle channel, Run run, Boolean isLast, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.Execute(IWriteBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.ExecuteWriteOperation[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteWriteOperation[TResult](IWriteOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionBase`1.UpdateOne(FilterDefinition`1 filter, UpdateDefinition`1 update, UpdateOptions options, CancellationToken cancellationToken)
at QuoteStar.MongoRepositories.MongoRepository`1.Update[T](Expression`1 expression, T item)

Inner Exception 1:
EndOfStreamException: Attempted to read past the end of the stream.

Comment by Stephen Weaver [ 09/Sep/14 ]

Has this been addressed? I'm running into the same problem when running RunCommand and executing replSetReconfig.

I can make this happen at will. It will happen every time the configuration is different than the previous call to replSetReconfig. If I run the same command twice in a row, the second one works just fine.

at MongoDB.Bson.IO.ByteBufferFactory.LoadFrom(Stream stream)
at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings readerSettings, IBsonSerializer serializer, IBsonSerializationOptions serializationOptions)
at MongoDB.Driver.Operations.CommandOperation`1.Execute(MongoConnection connection)
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand command, IBsonSerializer resultSerializer, IBsonSerializationOptions resultSerializationOptions)
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand command)
at MongoDB.Driver.MongoDatabase.RunCommand(IMongoCommand command)
at [MYCODE]

Made a new issue because this one is closed: (https://jira.mongodb.org/browse/CSHARP-1059)

Comment by Blake Niemyjski [ 11/Mar/14 ]

I'm not sure as this error happens randomly. We have a bunch from last two weeks at random and then one two months ago and then one 10 months ago. We did make this change (https://github.com/exceptionless/Exceptionless/commit/70cbb061c326189ca5262cd9c8d3de305c6f01da) as we seen it was really expensive.. take a look at line 484 on Error Repository. Since pushing we haven't seen anything happen but then again this error was random. I'll let you know if we see it again, but I figured I would report it just to be safe .

Comment by Craig Wilson [ 11/Mar/14 ]

Hey Blake, thanks for the report (and thanks for testing with the 1.9 rc0).

Just to clarify what you saying: Now that you have fixed the "not" problem, you are not experiencing this issue any longer. Is this correct? It still sounds like something is going on, but it's good there is a way to workaround it.

Craig

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