title: MongoDB - The wait queue for acquiring a connection to server is full
body: <p>I am using the below code to connect mongo DB.</p>
  
  <pre><code>public static class MongoDBHandler
  {
      static IMongoClient _client;
      static IMongoDatabase _database;
      static string MongoDBConnectionString;
  
      static IMongoClient mClientConnection()
      {
          MongoDBConnectionString = System.Configuration.ConfigurationManager.AppSettings["connectionString"];
          _client = new MongoClient(MongoDBConnectionString);
          return _client;
      }
  
      public static IMongoDatabase mDatabase()
      {
          try
          {
              if (_client == null)
              {
                  _client = mClientConnection();
              }
  
              if (_database == null)
              {
                  var mongoUrl = new MongoUrl(MongoDBConnectionString);
                  _database = _client.GetDatabase(mongoUrl.DatabaseName);
              }
              return _database;
          }
          catch
          {
              throw;
          }
      }
  }
  </code></pre>
  
  <p>I am using above class code like below:-</p>
  
  <pre><code>protected static IMongoDatabase _database;
  
  public void GetData()
  {
      _database = Assistant.MongoDBHandler.mDatabase();
      IMongoCollection&lt;Models.RoomTypeMappingOnline&gt; collection_rto = _database.GetCollection&lt;Models.RoomTypeMappingOnline&gt;("collection");
      //Rest of code
  }
  </code></pre>
  
  <p>My code is working fine. I am able to get the data without any issues with less number of request.</p>
  
  <p>But when I am getting more request, then I am getting the "The wait queue for acquiring a connection to server is full" error.</p>
  
  <p>Below is my connection string:-</p>
  
  <pre><code>mongodb://admin:password@server:11111/databse?authSource=sa&amp;appName=database&amp;connectTimeoutMS=5000&amp;minPoolSize=3000&amp;retryWrites=true&amp;waitQueueMultiple=15
  </code></pre>
  
  <p>Please suggest what changes I can made to my code so that it can work without error.</p>