[ 
https://issues.apache.org/jira/browse/CAMEL-12142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16325665#comment-16325665
 ] 

ASF GitHub Bot commented on CAMEL-12142:
----------------------------------------

GitHub user fhassak opened a pull request:

    https://github.com/apache/camel/pull/2176

    CAMEL-12142 : default mongodb host

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/fhassak/camel CAMEL-12142

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/2176.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2176
    
----
commit 5931c47e257a9d86e9a01eadff74ea7d4377210c
Author: Farès Hassak <fares.hassak@...>
Date:   2018-01-13T19:49:51Z

    CAMEL-12142 : default mongodb host

----


> 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