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

The connection pool is in paused state for server xxxx.hajp2.mongodb.net:27017

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.16.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      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}.");
              }
          }
      }
       
      

       

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            datateam@nominow.com Michael Hensen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: