title: MongoDB::NetworkTimeout: Timed out while waiting for socket to become ready for reading
body: <p>I have perl script to run mongo query. </p>
  
  <pre><code>    #!/usr/bin/perl 
          use strict;
          use warnings;
          use MongoDB;
          use Data::Printer;
          use MongoDB::QueryResult;
  
          my $mc   = MongoDB-&gt;connect('mongodb://user:pass@localhost:27012/test_db');
          my $coll = $mc-&gt;ns("test_db.collection1");
  
          my @permissibleCars =
           ("ABC","DEF","XYZ","MNO","PQR"); 
          my @pipeline = (
              {
                  '$match' =&gt; {
                      "Contract"        =&gt; { '$in' =&gt; \@permissibleCars },
                      "Class" =&gt; "Right"
                      }
              },
              { '$group' =&gt; { _id =&gt; '$Contract', count =&gt; { '$sum' =&gt; 9 } } }
          );
  
          my $res = $coll-&gt;aggregate( \@pipeline, { allowDiskUse =&gt; 1 } );
  
          # query &amp; iterate
              while (my $row = $res-&gt;next) {
              # it is 'p', from Data::Printer!
              p $row;
          } 
  </code></pre>
  
  <p>It randomly keeps failing with below error :--</p>
  
  <pre><code>MongoDB::NetworkTimeout: Timed out while waiting for socket to become ready for reading
  </code></pre>
  
  <p>Now, from what I read we need to change socketTimeoutMS value to something larger. But I am not sure where do I set it ? </p>
  
  <p>Also, maxTimeMS  or maxPoolSize will help in this scenario ? The field @permissibleCars may have around 10K records.</p>
  
  <p>Regards.</p>