Farès Hassak created CAMEL-12142:
------------------------------------

             Summary: Tests failed because of incorrect mongodb host
                 Key: CAMEL-12142
                 URL: https://issues.apache.org/jira/browse/CAMEL-12142
             Project: Camel
          Issue Type: Bug
          Components: camel-mongodb, camel-mongodb3
         Environment: 
 

            Reporter: Farès Hassak


Hello,

The tests have failed in component camel-mongodb, camel-mongodb3, 
camel-mongodb-gridfs:
{noformat}
com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to 
connect. Client view of cluster state is {type=UNKNOWN, 
servers=[{address=0.0.0.0:25313, type=UNKNOWN, state=CONNECTING, 
exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, 
caused by {java.net.SocketTimeoutException: connect timed out}}]
        at 
com.mongodb.connection.BaseCluster.getDescription(BaseCluster.java:167)
        at com.mongodb.Mongo.getConnectedClusterDescription(Mongo.java:881)
        at com.mongodb.Mongo.createClientSession(Mongo.java:873)
        at com.mongodb.Mongo$3.getClientSession(Mongo.java:862)
        at com.mongodb.Mongo$3.execute(Mongo.java:830)
        at 
com.mongodb.MongoCollectionImpl.executeDrop(MongoCollectionImpl.java:790)
        at com.mongodb.MongoCollectionImpl.drop(MongoCollectionImpl.java:780)
        at 
org.apache.camel.component.mongodb.AbstractMongoDbTest.doPostSetup(AbstractMongoDbTest.java:60)
        at 
org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:271)
{noformat}

Because the client is using the wrong address when connecting to mongodb:

{noformat}
address=0.0.0.0
{noformat}

The MongoClient is created here :

{code:java}

 public class EmbedMongoConfiguration {

 @Bean
 public MongoClient myDb() throws UnknownHostException {
        return new MongoClient("0.0.0.0", PORT);
    }
}
{code}


I suggest to use the default mongodb host : 

{noformat}
127.0.0.1
{noformat}

As défined in ServerAdress class in mongodb java driver :


{code:java}

public class ServerAddress implements Serializable {
  
    /**
     * Returns the default database host: "127.0.0.1"
     *
     * @return IP address of default host.
     */
    public static String defaultHost() {
        return "127.0.0.1"; // NOPMD
   } 
}
{code}

The EmbedMongoConfiguration class should return a Mongclient object with 
default mongodb host :


{code:java}
 public class EmbedMongoConfiguration {

 @Bean
 public MongoClient myDb() throws UnknownHostException {
        return new MongoClient(defaultHost(), PORT);
    }
}
{code}


Here my configuration :


{noformat}
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 
2017-10-18T09:58:13+02:00)
Maven home: D:\apache-maven-3.5.2\bin\..
Java version: 1.8.0_152, vendor: Oracle Corporation
Java home: D:\jdk1.8.0_152\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
{noformat}


Farès



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to