title: correct way C# exception handling for Mongo DB connections
body: <p>my mongoDB is hosted on Mongo Lab and i am using C# as the code to retrieve the data. </p>
  
  <p>1 out of 10 times the mongo query throws an exception:</p>
  
  <pre><code>System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
  </code></pre>
  
  <p>I asked MongoLab to investigate the log report for that time duration and they said there was nothing logged in from their side and advised me to use correct mongo exception handling.</p>
  
  <p>My Question: How should i handle Mongo exceptions in C#? </p>
  
  <p>Should i do it as follows. Query again inside catch once or twice:</p>
  
  <pre><code>   /*Connection part
  
      ----
      ----
      */
      List X&lt;XYZ&gt; = new List&lt;XYZ&gt;;
      try{
      var Query = from o in collection.AsQueryable&lt;XYZ&gt;()
                               where ...
                               select o;
  
      List= Query.ToList();
      }
      catch(MongoException e){
  var Query = from o in collection.AsQueryable&lt;XYZ&gt;()
                               where ...
                               select o;
      List= Query.ToList();
      }
  </code></pre>
  
  <p>Thanks for helping in advance. </p>