I have been using a local Docker image of Mongo for development. Now I’m trying to use a Serverless instance and the code is failing with “The connection pool is in paused state…”. The code works with local Docker image and with a free instance of Atlas (only changing connection string).
I’m using V2.15.1 of the .NET Driver.
The stack trace is:
Unhandled exception: MongoDB.Driver.MongoConnectionPoolPausedException: The connection pool is in paused state for server tenantserverless-lb.dsets.mongodb.net:27017.
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.PoolState.ThrowIfNotReady()
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.StartCheckingOut()
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionHelper.AcquireConnectionAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquireConnectionAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.GetChannelAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.RetryableReadContext.InitializeAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.RetryableReadContext.CreateAsync(IReadBinding binding, Boolean retryRequested, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ListDatabasesOperation.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.ListDatabaseNamesAsync(IClientSessionHandle session, ListDatabaseNamesOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
at TenantMongoDb.Api.MongoDbTools.CreateDatabase(String connectionString, String databaseName, Boolean clobber) in E:\GitHub\daciertech\carbon\src\CarbonEntities\TenantMongoDb.Api\MongoDbTools.cs:line 24
The code is (last line is line 24 of MongoDbTools.cs):
var settings = MongoClientSettings.FromConnectionString(connectionString);
settings.ApplicationName = "Appname";
settings.ServerApi = new ServerApi(ServerApiVersion.V1);
settings.UseTls = true;
settings.SdamLogFilename = @"sdam.log";
var client = new MongoClient(settings);
var dbNames = (await client.ListDatabaseNamesAsync().ConfigureAwait(false)).ToList();
The sdam.log file is empty.
The connection string that works is:
mongodb+srv://<username>:<password>@jvcluster.wcszc.mongodb.net/?retryWrites=true&w=majority
The connection string that fails is:
mongodb+srv://<username>:<password>@tenantserverless.dsets.mongodb.net/?retryWrites=true&w=majority
What am I doing wrong? Thanks!
