[CSHARP-2621] Connection reset by peer Created: 28/May/19  Updated: 25/Jun/20  Resolved: 25/Jun/20

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

Type: Bug Priority: Major - P3
Reporter: Riaz Ahmad Assignee: Wan Bachtiar
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I am getting a "Connection reset by peer" message periodically throughout the day.  I have microservices running .net core 2.1 and .net core 2.2 and both are throwing this exception.

 

The exception is thrown when doing simple Find queries.  I don't have any custom timeout settings applied on MongoClient to setup the connection.  I have the connection setup as a singleton to allow MongoClient to grab a connection from the connection pool it manages.

 

Looking at .net core 2.1 issues, there is a reported defect on this as they have optimized their connection code.  I am wondering if the two are related.

See Sockets Performance and SocketsHttpHandler

https://devblogs.microsoft.com/dotnet/announcing-net-core-2-1-preview-2/

Github Defect

https://github.com/dotnet/corefx/issues/32305

I have tried setting DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER environment variable as noted in the above links, but that does not resolve the issue.

 

Here is the exception details:

MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer

at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()



 Comments   
Comment by Rachelle Palmer [ 25/Jun/20 ]

Hi there, thank you for reaching out to MongoDB. As this sounds more like a support issue, I wanted to give you some resources to get this question answered more quickly:

  • our MongoDB support portal, located at support.mongodb.com
  • our MongoDB community forums, located here
  • If you are an Atlas customer, there is free support offered 24/7 in the lower right hand corner of the UI.

Thank you!
Rachelle

Comment by Riaz Ahmad [ 23/Jul/19 ]

This issue looks to be related to CSHARP-2648

Comment by Riaz Ahmad [ 30/May/19 ]

Environment - Ubuntu Bionic 18.04 & Ubuntu Trusty 14.04

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