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

Messy way to determine if a Client connection is successful

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Cluster Management
    • None

    Description

      Currently, when you try to connect to a remote MongoDB server, the connection will appear to be successful even though the remote server is down. The only indication is from the log messages but the Java API continues as normal.

      To make a connection and then check the connection is successful then Java programs need do something similar to the following...

      MongoClient mongoClient = new MongoClient();
      mongoClient.getAddress();

      I'd expect the first line to throw an exception if a connection to any server (in a server list say) failed but it doesn't so the second line is required in order to do it. Very annoying.

      I propose that either an immediate MongoException is thrown by the MongoClient or you introduce a method where the connection can be tested (e.g. an isClosed or whatever method on the MongoClient class). Both would be good though. One for immediate connection problems and the other for subsequent checks by the application.

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            aharris Andrew Harris
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: