title: Accessing MongoDB through Android app. Not Working
body: <p>Things I Have tried:</p>
  
  <pre><code>InetAddress address = InetAddress.getByName("MyPCName");
  
  MongoClientOptions.Builder builder = MongoClientOptions.builder().connectTimeout(3000);
  MongoClient mongo = new MongoClient(new ServerAddress(address.getHostAddress(), 3001), builder.build());
          try {
              mongo.getAddress();
          } catch (Exception e) {
              System.out.println("Mongo is down");
              mongo.close();
          }
  </code></pre>
  
  <p>Second try:</p>
  
  <pre><code>InetAddress address = InetAddress.getByName("MyPCName");
  MongoClientURI uri = new MongoClientURI( "mongodb://"+address.getHostAddress()+":27017/"+TEST_SKETCH_APP );
  
  MongoClient instance = MongoDatabaseConnection.getInstance(uri);
  try {
              instance .getAddress();
          } catch (Exception e) {
              System.out.println("Mongo is down");
              instance .close();
          }
  </code></pre>
  
  <p>FireWall configured properly :</p>
  
  <pre><code>netsh advfirewall firewall add rule name="Allowing mongod" dir=in action=allow program=" C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe"
  </code></pre>
  
  <p>But Still when I try to connect to do an insert operation I get this error message :</p>
  
  <pre><code>Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=192.168.138.1:3001, type=Unknown, state=Connecting}]
  </code></pre>
  
  <p>I am doing the save operation in an AsyncTask. My mongo db server is running in the "MyPCName" computer. My Mongodb config has bind ip commented too. And I have also tried the bind Ip to keep this <code>bind_ip = 127.0.0.1,***.***.***.*,0.0.0.0</code>
  The '*' mark is the ip address which I get when I do a <code>address.getHostAddress()</code>.</p>
  
  <p>I am now stuck here.</p>