Reputation: 1484
I have turn on the port-forward with rhc, it shows mongodb 127.0.0.1:27017 => xxx.x.xxx.x:27017 doc here port-forward
but I still have no luck connect to that mongodb cartridge. I've try both mongo shell 3.0 and java MongoClient.
mongo shell return error 10061
java return com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting for a server that matches AnyServerSelector{}
what else could I try to connect to openshift mongodb remotely?
my code, I've test this on local mongodb which works fine
String mongoUri = "mongodb://admin:[email protected]:27017/";
MongoClient mongoClient;
try {
mongoClient = new MongoClient(new MongoClientURI(mongoUri));
DB db = mongoClient.getDB("mycoll");
DBCollection cc = db.getCollection("DBObject");
cc.insert(dbo);
}
Upvotes: 2
Views: 682
Reputation:
You should be using the following connection string locally while you have port forwarding enabled:
String mongoUri = "mongodb://admin:[email protected]:27017/";
Since the connection is being forwarded over an ssh tunnel, you need to use the local port. See this answer for more information: OpenShift: How to connect to postgresql from my PC
Upvotes: 0