Details
-
Bug
-
Resolution: Fixed
-
Unknown
-
None
-
None
-
None
-
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}."); |
}
|
}
|
}
|
|
Attachments
Issue Links
- duplicates
-
CSHARP-3947 Update serverless testing for load balancer fronting single proxy
-
- Closed
-