Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-310

Driver reconnect does not detect network IP changes.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.0, 3.0.0
    • Affects Version/s: None
    • Component/s: Connection Management
    • Labels:
      None
    • Environment:
      Mac OS X
      java version "1.6.0_22"
      Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-9M3263)
      Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)

      Our application runs on machines that are sometimes moved between networks or has its IP address changed.

      When we create the Mongo instance it is done using the "localhost" host for the Mongo server. The Mongo driver appears to always resolve to an IP on the local subnet. "192.168.0.10" for example. When the network chances however, our applications starts failing with errors like the following because it can no longer connect:

      jvm 1 | java.io.IOException: couldn't connect to [io/192.168.0.10:27017] bc:java.net.ConnectException: Operation timed out
      jvm 1 | at com.mongodb.DBPort._open(DBPort.java:205)
      jvm 1 | at com.mongodb.DBPort.go(DBPort.java:94)
      jvm 1 | at com.mongodb.DBPort.go(DBPort.java:75)
      jvm 1 | at com.mongodb.DBPort.call(DBPort.java:65)
      jvm 1 | at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:215)
      jvm 1 | at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
      jvm 1 | at com.mongodb.DBCursor._check(DBCursor.java:354)
      jvm 1 | at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
      jvm 1 | at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
      jvm 1 | at com.mongodb.jdbc.MongoResultSet.next(MongoResultSet.java:640)
      ...

      I have configured the Mongo instance to automatically try to reconnect, but the conversion from "localhost" to "192.168.0.10" only happens once. The only way to get Mongo to reconnect is to restart the Java instance.

      I assume that there is a reason why the IP is being resolved, but would it be possible to make the driver re-resolve the IP when doing a reconnect?

      Thanks in advance,
      Leif

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            leif Leif Mortenson
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: