[CSHARP-1059] RunCommand replSetReconfig System.IO.EndOfStreamException: Attempted to read past the end of the stream. Created: 09/Sep/14  Updated: 05/Feb/18  Resolved: 05/Feb/18

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

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

Windows 8
Microsoft Windows Server 2008 R2 Standard


Issue Links:
Backports
backports CSHARP-2146 System.IO.EndOfStreamException when i... Closed

 Description   

Every time the configuration is different than the previous call to replSetReconfig, RunCommand on the MongoDatabase object in the C# driver throws the following exception.

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]



 Comments   
Comment by Robert Stam [ 05/Feb/18 ]

The server closed the socket which results in the reader getting an EndOfStreamException.

Comment by Stephen Weaver [ 10/Sep/14 ]

Ok, that makes sense. Thanks for the quick response, Craig.

Comment by Craig Wilson [ 09/Sep/14 ]

Hi Stephen,

Yes, it will work. MongoDB kills the connections when a node changes from and to certain states. This manifests itself to us as an end of stream as we are expecting a reply from a command like this, but it will never come. And since we don't necessarily know what command you are running, there isn't a whole lot we can do to make this a better message. I'll leave this open to see if we can come up with something.

Thanks for the report.

Comment by Stephen Weaver [ 09/Sep/14 ]

It is interesting to note that reconfigure does work even when the exception is thrown.

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