Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3578

.NET 5: Received an unexpected EOF or 0 bytes from the transport stream.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Unknown Unknown
    • None
    • 2.12.1
    • None
    • None

    Description

      We are receiving EOF exceptions on ~5% of total mongo queries. Exceptions are more visible during higher load but does not depend on high load only.

      CPU usage on MongoDB: 5-20%
      RAM usage on MongoDB: 50-70%
      Active connections on MongoDB: 350-450

      Mongo connection configuration with socket configuration fromĀ CSHARP-1151

      string connectionString = "...&replicaSet=replset&maxPoolSize=200";
      string databaseName = "...";
       
      MongoClientSettings clientSettings = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
       
      Action<Socket> socketConfigurator = s => s.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, 120);
      clientSettings.ClusterConfigurator = cb => cb.ConfigureTcp(tcp => tcp.With(socketConfigurator: socketConfigurator));
       
      X509Certificate2 certificate = GetCertificate();
      clientSettings.SslSettings = new SslSettings
      {
      	ClientCertificates = new[] { certificate }
      };
      clientSettings.UseTls = true;
       
      services.AddSingleton(new MongoClient(clientSettings).GetDatabase(databaseName));
      

      Exception:

      An exception occurred while opening a connection to the server. Received an unexpected EOF or 0 bytes from the transport stream.
      

      Exception call stack:

      MongoDB.Driver.MongoConnectionException:
         at MongoDB.Driver.Core.Connections.BinaryConnection+<OpenHelperAsync>d__51.MoveNext
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw 
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess 
         at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification 
         at MongoDB.Driver.Core.Servers.Server+<GetChannelAsync>d__34.MoveNext
         ...
      Inner exception System.IO.IOException handled at MongoDB.Driver.Core.Connections.BinaryConnection+<OpenHelperAsync>d__51.MoveNext:
         at System.Net.Security.SslStream+<ReceiveBlobAsync>d__172`1.MoveNext 
         at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw 
         at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess 
         at System.Net.Security.SslStream+<ForceAuthenticationAsync>d__171`1.MoveNext 
         ...
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            m.stirbys@hyarchis.com Modestas Stirbys
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: