[CSHARP-4174] The connection pool is in paused state for server xxxx.hajp2.mongodb.net:27017 Created: 13/May/22  Updated: 28/Oct/23  Resolved: 10/Jun/22

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

Type: Bug Priority: Unknown
Reporter: Michael Hensen Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-3947 Update serverless testing for load ba... Closed
Backwards Compatibility: Minor Change

 Description   

Every time I start my api service and make the first call to a serverless instance of mongo on Atlas I will receive a MongoConnectionPoolPausedException .. 
the second call will come through and works as expected.. But I need the firt call to start working and not from the 2nd one on..

code to try is like:
{{}}

 

using Microsoft.AspNetCore.Mvc;
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace INow.Mongo.Service.Controllers
{
    [Route("api/[Controller]")]
    [ApiController]
    public class serverlesstest : ControllerBase
    {
        private MongoClient client;
        [HttpGet("GetCollectionServerless")]
        public async Task<JsonResult> GetCollectionWithConnectionString([FromQuery] string connectionString, [FromQuery] string databaseName, [FromQuery] string collectionName)
        {
            client = new MongoClient(connectionString);
            IMongoDatabase database = client.GetDatabase(databaseName);
            var collection = database.GetCollection<BsonDocument>(collectionName);
            List<BsonDocument> ResultList = new List<BsonDocument>();
            try
            {
                ResultList = await collection.Find(Builders<BsonDocument>.Filter.Empty).ToListAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                if (ex is MongoConnectionPoolPausedException)
                {
                    return new JsonResult(ex.Message);
                }
            }
            return new JsonResult($"found {ResultList.Count} item in collection {collectionName}.");
        }
    }
}
 

 



 Comments   
Comment by James Kovacs [ 10/Jun/22 ]

Author:

{'name': 'Dmitry Lukyanov', 'email': 'dmitry.lukyanov@mongodb.com', 'username': 'DmitryLukyanov'}

Message: CSHARP-3947: Update serverless testing for load balancer fronting single proxy. (#791)

CSHARP-3947: Update serverless testing for load balancer fronting single proxy.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/50f6cb8017d4a406f32a729f5ab915b7ca7e677f

Comment by Dmitry Lukyanov (Inactive) [ 19/May/22 ]

datateam@nominow.com, our investigation of this issue indicates that it was fixed as part of CSHARP-3947, which will be released with 2.16.0. Please try the new release when it is available and re-open this issue with a comment if you are still experiencing the issue

Comment by Dmitry Lukyanov (Inactive) [ 17/May/22 ]

datateam@nominow.com thank you for your report, we will look at this and come back to you.

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