vert-x3 / vertx-mongo-client

Mongo Client for Eclipse Vert.x
http://vertx.io
Apache License 2.0
60 stars 99 forks source link

Unable to connect to mongo DB using vertx mongo client. #220

Closed sidvanarse closed 4 years ago

sidvanarse commented 4 years ago

Hi I am getting following exception when i try to connect to mongoDB using vertx jmongo client. However i am able to connect to mongoDB using java mongodb driver client. So seems to be issue with vertx mongo client only.

No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoException: java.io.IOException: ConnectEx failed}, caused by {java.io.IOException: ConnectEx failed}}]}. Waiting for 30000 ms before timing out

kostya05983 commented 4 years ago

Hello, can you provide a part of code how you try to connect?

sidvanarse commented 4 years ago

Code is very simple. PFB:

 JsonObject mongoconfig = new JsonObject()
        .put("connection_string", "mongodb://localhost:27017")
        .put("db_name", "test");

MongoClient mongoClient = MongoClient.createShared(vertx, mongoconfig);

JsonObject document = new JsonObject()
  .put("title", "The Hobbit");

mongoClient.save("books", document, res -> {
  if (res.succeeded()) {
    String id = res.result();
    System.out.println("Saved book with id " + id);
  } else {
    res.cause().printStackTrace();
  }
});
limadelrey commented 4 years ago

@sidvanarse Still needing help?

karianna commented 4 years ago

no response so closing