Infinite number of logins being generated to the MongoDB from a single call from a C#.net MongoDB.Driver version 2.17.1 application

I am fairly new to using MongoDB Community edition and I am hoping someone can tell me that this can be corrected with a simple MongoClientSettings change. What I am seeing in the mongo log file is what looks like a keep alive login once a second that goes on forever until I stop the Web Service in Azure, long after the C#.net code has executed and the garbage collection has happened. My Azure Logging for the application only shows the code executed once. I have tried this with MongoDB Community version 4.0, 4.2 and 5.0.9 and MongoDB.Driver versions 2.6.1 to 2.17.1and it happens on all of them. Below is a copy of the C#.Net code and you can see it is deleting users from a database and then the database however this infinite logging is happening even on simple record fetches as well. I can only assume it is some ClientSetting I am missing to tell the MongoDB.Driver not to try and keep the thread alive past a certain point but, as you can see from the code, I have almost run out of settings to try at this point. Any suggestions are welcome. This has become a major problem in the size of my logs and I am having to cycle my Web Services every night because of this. Thanks in advance for your input.

C#.Net Code

        public async Task<IHttpActionResult> DataStorageDestroyAsync(int companyId, string userEmail)
        {
            Trace.TraceInformation("DataStorageAPI > UtilityController > DataStorageDestroyAsync Started.");
            string retStatus = "Failed";

            try
            {
                Trace.TraceInformation("DataStorageAPI > UtilityController > DataStorageDestroyAsync - companyId:" + companyId + ";");
                Trace.TraceInformation("DataStorageAPI > UtilityController > DataStorageDestroyAsync - userEmail:" + userEmail + ";");
            }
            catch (Exception) { }

            try
            {
                string databaseName = "DataStorage" + companyId.ToString();
                try
                {
                    Trace.TraceInformation("DataStorageAPI > UtilityController > DataStorageDestroyAsync - databaseName:" + databaseName + ";");
                }
                catch (Exception) { }

                if (!string.IsNullOrEmpty(databaseName))
                {
                    var connectionString = CryptoUtility.GetDecryptedString(System.Configuration.ConfigurationManager.ConnectionStrings["MongoDBContext"].ConnectionString);

                    MongoClientSettings settings = MongoClientSettings.FromUrl(
                      new MongoUrl(connectionString)
                    );

                    settings.ApplicationName = "DHC_DataStorage.API.DataStorageDestroy";
                    settings.ConnectTimeout = TimeSpan.FromSeconds(1);
                    settings.HeartbeatInterval = TimeSpan.FromSeconds(7);
                    settings.HeartbeatTimeout = TimeSpan.FromSeconds(8);
                    settings.MaxConnectionIdleTime = TimeSpan.FromSeconds(2);
                    settings.MaxConnectionLifeTime = TimeSpan.FromSeconds(3);
                    settings.MaxConnectionPoolSize = 10000;
                    settings.MinConnectionPoolSize = 1;
                    settings.LocalThreshold = TimeSpan.FromMilliseconds(20);
                    settings.ServerSelectionTimeout = TimeSpan.FromSeconds(5);
                    settings.SocketTimeout = TimeSpan.FromSeconds(4);
                    settings.WaitQueueTimeout = TimeSpan.FromSeconds(6);


                    MongoClient mongoClient = new MongoClient(settings);

                    var db = mongoClient.GetDatabase(databaseName);

                    //Deleting all users in the database.
                    var command = @"{ dropAllUsersFromDatabase: 1, writeConcern: {w: ""majority"" }}";
                    await db.RunCommandAsync<BsonDocument>(command);

                    //Drop a MongoDB database and contained collections.
                    CancellationToken cancellationToken = new CancellationToken();
                    mongoClient.DropDatabase(databaseName, cancellationToken);

                    retStatus = "Success";
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("DataStorageAPI > UtilityController > DataStorageDestroyAsync Failed. Error:" + ex.ToString());
                retStatus = "Failed";
            }

            //********************************************************************************
            //End DataStorageDestroy
            //********************************************************************************
            Trace.TraceInformation("DataStorageAPI > UtilityController > DataStorageDestroyAsync Ended.");

            return Ok(retStatus);
        }

A snippet of the MongoDB Log that is filled with continuous Login calls

2022-08-10T09:33:39.825+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39127 (3 connections now open)
2022-08-10T09:33:39.826+0000 I NETWORK  [conn39127] received client metadata from 52.153.231.234:43777 conn39127: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:33:39.888+0000 I ACCESS   [conn39127] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:34:39.883+0000 I NETWORK  [conn39127] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:34:39.930+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39128 (3 connections now open)
2022-08-10T09:34:39.931+0000 I NETWORK  [conn39128] received client metadata from 52.153.231.234:43776 conn39128: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:34:39.996+0000 I ACCESS   [conn39128] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:35:39.991+0000 I NETWORK  [conn39128] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:35:39.999+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39129 (3 connections now open)
2022-08-10T09:35:40.000+0000 I NETWORK  [conn39129] received client metadata from 52.153.231.234:43777 conn39129: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:35:40.064+0000 I ACCESS   [conn39129] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:36:40.054+0000 I NETWORK  [conn39129] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:36:40.069+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39130 (3 connections now open)
2022-08-10T09:36:40.070+0000 I NETWORK  [conn39130] received client metadata from 52.153.231.234:43776 conn39130: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:36:40.141+0000 I ACCESS   [conn39130] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:37:40.135+0000 I NETWORK  [conn39130] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:37:40.151+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39131 (3 connections now open)
2022-08-10T09:37:40.152+0000 I NETWORK  [conn39131] received client metadata from 52.153.231.234:43777 conn39131: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:37:40.217+0000 I ACCESS   [conn39131] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:38:40.211+0000 I NETWORK  [conn39131] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:38:40.228+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39132 (3 connections now open)
2022-08-10T09:38:40.228+0000 I NETWORK  [conn39132] received client metadata from 52.153.231.234:43776 conn39132: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:38:40.295+0000 I ACCESS   [conn39132] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:39:40.287+0000 I NETWORK  [conn39132] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:39:40.299+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39133 (3 connections now open)
2022-08-10T09:39:40.300+0000 I NETWORK  [conn39133] received client metadata from 52.153.231.234:43777 conn39133: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:39:40.366+0000 I ACCESS   [conn39133] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:40:40.363+0000 I NETWORK  [conn39133] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:40:40.381+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39134 (3 connections now open)
2022-08-10T09:40:40.382+0000 I NETWORK  [conn39134] received client metadata from 52.153.231.234:43776 conn39134: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:40:40.449+0000 I ACCESS   [conn39134] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:41:40.446+0000 I NETWORK  [conn39134] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:41:40.474+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39135 (3 connections now open)
2022-08-10T09:41:40.474+0000 I NETWORK  [conn39135] received client metadata from 52.153.231.234:43777 conn39135: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:41:40.539+0000 I ACCESS   [conn39135] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:42:40.551+0000 I NETWORK  [conn39135] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:42:40.567+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39136 (3 connections now open)
2022-08-10T09:42:40.568+0000 I NETWORK  [conn39136] received client metadata from 52.153.231.234:43776 conn39136: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:42:40.629+0000 I ACCESS   [conn39136] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:43:40.639+0000 I NETWORK  [conn39136] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:43:40.653+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39137 (3 connections now open)
2022-08-10T09:43:40.653+0000 I NETWORK  [conn39137] received client metadata from 52.153.231.234:43777 conn39137: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:43:40.714+0000 I ACCESS   [conn39137] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:44:40.718+0000 I NETWORK  [conn39137] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:44:40.732+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39138 (3 connections now open)
2022-08-10T09:44:40.733+0000 I NETWORK  [conn39138] received client metadata from 52.153.231.234:43776 conn39138: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:44:40.795+0000 I ACCESS   [conn39138] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:45:40.816+0000 I NETWORK  [conn39138] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:45:40.832+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39139 (3 connections now open)
2022-08-10T09:45:40.832+0000 I NETWORK  [conn39139] received client metadata from 52.153.231.234:43777 conn39139: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:45:40.895+0000 I ACCESS   [conn39139] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:46:40.907+0000 I NETWORK  [conn39139] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:46:40.927+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39140 (3 connections now open)
2022-08-10T09:46:40.927+0000 I NETWORK  [conn39140] received client metadata from 52.153.231.234:43776 conn39140: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:46:40.990+0000 I ACCESS   [conn39140] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:47:40.993+0000 I NETWORK  [conn39140] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:47:41.012+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39141 (3 connections now open)
2022-08-10T09:47:41.017+0000 I NETWORK  [conn39141] received client metadata from 52.153.231.234:43777 conn39141: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:47:41.090+0000 I ACCESS   [conn39141] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:48:41.098+0000 I NETWORK  [conn39141] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:48:41.114+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39142 (3 connections now open)
2022-08-10T09:48:41.114+0000 I NETWORK  [conn39142] received client metadata from 52.153.231.234:43776 conn39142: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:48:41.179+0000 I ACCESS   [conn39142] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:49:41.183+0000 I NETWORK  [conn39142] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:49:41.198+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39143 (3 connections now open)
2022-08-10T09:49:41.199+0000 I NETWORK  [conn39143] received client metadata from 52.153.231.234:43777 conn39143: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:49:41.263+0000 I ACCESS   [conn39143] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:50:41.267+0000 I NETWORK  [conn39143] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:50:41.290+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39144 (3 connections now open)
2022-08-10T09:50:41.291+0000 I NETWORK  [conn39144] received client metadata from 52.153.231.234:43776 conn39144: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:50:41.354+0000 I ACCESS   [conn39144] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:51:41.348+0000 I NETWORK  [conn39144] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:51:41.365+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39145 (3 connections now open)
2022-08-10T09:51:41.366+0000 I NETWORK  [conn39145] received client metadata from 52.153.231.234:43777 conn39145: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:51:41.431+0000 I ACCESS   [conn39145] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:52:41.426+0000 I NETWORK  [conn39145] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:52:41.443+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39146 (3 connections now open)
2022-08-10T09:52:41.444+0000 I NETWORK  [conn39146] received client metadata from 52.153.231.234:43776 conn39146: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:52:41.509+0000 I ACCESS   [conn39146] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:53:41.504+0000 I NETWORK  [conn39146] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:53:41.519+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39147 (3 connections now open)
2022-08-10T09:53:41.520+0000 I NETWORK  [conn39147] received client metadata from 52.153.231.234:43777 conn39147: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:53:41.603+0000 I ACCESS   [conn39147] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:54:41.609+0000 I NETWORK  [conn39147] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:54:41.624+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39148 (3 connections now open)
2022-08-10T09:54:41.625+0000 I NETWORK  [conn39148] received client metadata from 52.153.231.234:43776 conn39148: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:54:41.689+0000 I ACCESS   [conn39148] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:55:41.690+0000 I NETWORK  [conn39148] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:55:41.709+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39149 (3 connections now open)
2022-08-10T09:55:41.710+0000 I NETWORK  [conn39149] received client metadata from 52.153.231.234:43777 conn39149: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:55:41.783+0000 I ACCESS   [conn39149] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:56:41.794+0000 I NETWORK  [conn39149] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:56:41.809+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39150 (3 connections now open)
2022-08-10T09:56:41.810+0000 I NETWORK  [conn39150] received client metadata from 52.153.231.234:43776 conn39150: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:56:41.882+0000 I ACCESS   [conn39150] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:57:41.878+0000 I NETWORK  [conn39150] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:57:41.895+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39151 (3 connections now open)
2022-08-10T09:57:41.895+0000 I NETWORK  [conn39151] received client metadata from 52.153.231.234:43777 conn39151: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:57:41.958+0000 I ACCESS   [conn39151] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:58:41.955+0000 I NETWORK  [conn39151] end connection 52.153.231.234:43777 (2 connections now open)
2022-08-10T09:58:41.969+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43776 #39152 (3 connections now open)
2022-08-10T09:58:41.969+0000 I NETWORK  [conn39152] received client metadata from 52.153.231.234:43776 conn39152: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:58:42.036+0000 I ACCESS   [conn39152] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T09:59:42.040+0000 I NETWORK  [conn39152] end connection 52.153.231.234:43776 (2 connections now open)
2022-08-10T09:59:42.055+0000 I NETWORK  [listener] connection accepted from 52.153.231.234:43777 #39153 (3 connections now open)
2022-08-10T09:59:42.055+0000 I NETWORK  [conn39153] received client metadata from 52.153.231.234:43777 conn39153: { application: { name: "DHC_DataStorage.API.DataStorageDestroy" }, driver: { name: "mongo-csharp-driver", version: "2.17.1.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.14393", architecture: "x86_32", version: "10.0.14393" }, platform: ".NET Framework 4.8.4480.0" }
2022-08-10T09:59:42.117+0000 I ACCESS   [conn39153] Successfully authenticated as principal emmongoadmin on admin
2022-08-10T10:00:42.141+0000 I NETWORK  [conn39153] end connection 52.153.231.234:43777 (2 connections now open)

Azure Log for the web service

date	level	applicationName	instanceId	eventTickCount	eventId	pid	tid	message
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	84	DHC_DataStorage > Api > Providers > CustomOAuthProvider > GrantResourceOwnerCredentials numRetries: 0
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	84	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - Start;
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	84	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - 406 - secret:CE7BA5CD-40AF-4D94-A39D-0D183A9F2EE5;
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	84	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - 406 - clientId:AccountAdmin;
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	82	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - Successful;
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	7	DataStorageAPI > UtilityController > DataStorageCreateAsync Started.
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	7	DataStorageAPI > UtilityController > DataStorageCreateAsync - companyId:159;
2022-08-09T21:47:25	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	7	DataStorageAPI > UtilityController > DataStorageCreateAsync - userEmail:twsilentdeath@hotmail.com;
2022-08-09T21:47:26	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	9	DHC_DataStorage > Data > MongoDataContext > Mongo MaxConnectionPoolSize:10000;
2022-08-09T21:47:26	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	9	DHC_DataStorage > Data > MongoDataContext > Mongo MinConnectionPoolSize:1;
2022-08-09T21:47:26	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	27688	81	DataStorageAPI > UtilityController > DataStorageCreateAsync Ended.
2022-08-09T22:03:36	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	10	DHC_DataStorage > Api > Providers > CustomOAuthProvider > GrantResourceOwnerCredentials numRetries: 0
2022-08-09T22:03:36	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	10	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - Start;
2022-08-09T22:03:36	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	10	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - 406 - secret:CE7BA5CD-40AF-4D94-A39D-0D183A9F2EE5;
2022-08-09T22:03:36	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	10	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - 406 - clientId:AccountAdmin;
2022-08-09T22:03:36	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	8	DH_Common > Services > ManagementAPIService > ValidateApiClientUser - Successful;
2022-08-09T22:03:37	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	5	DataStorageAPI > UtilityController > DataStorageDestroyAsync Started.
2022-08-09T22:03:37	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	5	DataStorageAPI > UtilityController > DataStorageDestroyAsync - companyId:159;
2022-08-09T22:03:37	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	5	DataStorageAPI > UtilityController > DataStorageDestroyAsync - userEmail:;
2022-08-09T22:03:37	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	5	DataStorageAPI > UtilityController > DataStorageDestroyAsync - databaseName:DataStorage159;
2022-08-09T22:03:37	Information	QADHCDataStorageAPI	2.17E+15	6.37957E+17	0	17260	10	DataStorageAPI > UtilityController > DataStorageDestroyAsync Ended.

If you increase logging on the server side you would probably see what this connection was doing while it’s connected to the server, my guess is that it’s probably complying with MongoDB driver spec by monitoring the state of the server/replica set.

Asya

Hi, @steve_mauldin,

You are modifying your default MongoClientSettings, notably setting MaxConnectionIdleTime to 2 seconds and MaxConnectionLifeTime to 3 seconds as well as MinConnectionPoolSize to 1. The net effect is that each connection pool - of which there will be one per replset cluster member - will maintain a minimum pool size of 1. You have also configured that connections can only remain idle for 2 seconds (MaxConnectionIdleTime) and MUST be reaped after 3 seconds regardless of how much or little they are used (MaxConnectionLifeTime). The net effect of these settings is that you are aggressively reaping connections in the pool, but requiring at least 1 connection in the pool resulting in rapid turnover of connections.

It is a bit curious that connections are turning over every second rather than every two seconds, but maybe those logs are from slightly different MongoClientSettings.

Settings MaxConnectionPoolSize to 10,000 is also not recommended. If you’re connecting to a 3-member replica set, you could potentially create over 30,000 connections from your app server to the cluster. I would encourage you to leave this value at the default of 100 unless you have a strong reason not to.

Overall I would suggest leaving the MongoClientSettings at their default values unless performance and scalability testing indicates better values for your application workload.

Sincerely,
James

2 Likes

James,

Thanks you for the reply. I initially was running with the default settings and was seeing the infinite pinging. What you are seeing on the settings now is about 200+ attempts over 30 days to try and guess how to get the thread to stop login in every minute. I have found little documentation on the different ClientSettings options. I am running aa single instance of community MongoDB. No Replication and No sharding. The connections are once per minute not once per second but over the course of a day the number of connections start to bloat the log file. I have set the Client Settings back to default and I am still seeing a once a minute login even though the calling code and object were long since garbage collected. I am at a loss for how to proceed at this point. Any advice on how to tell the C# MongoDB.Driver to stop the keep alive login ping would be greatly appreciated.

James,

I reread your post a second time and have reset EVERYTHING back to the defaults and the issue went away. The MinConnectionPoolSize=1 is what was causing what looked like an infinite keep-alive because the driver was maintaining at the minimum one thread alive even after my program had trash collected the MongoClient object. I was thinking, incorrectly, that once the MongoClient object got trash collected that is would no longer exist in memory but that is not the case for the Mongo.Driver at least on Azure. Only stopping and restarting the App Service would stop the Mongo.Driver from keeping that thread alive. The reason I had set MinConnectionPoolSize to 1 was after reading posts about improving your Mongo performance. We were having some throughput issues early on and that is also where the MaxConnectionPoolSize=10000 came from was our load testing very large datasets into our MongoDB. We have since created a front end queuing system and only allow a limited number of connections at a time for the queuing system and MaxConnectionPoolSize just never got set back to 100. Thanks again for your reply.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.