I am trying to connect to cloudantDB from local. This is the code that I get from the IBM example and it is working on deployed version online.
try {
System.out.println("Connecting to Cloudant : " + user);
//This works
CloudantClient client = ClientBuilder.account(user)
.username(user)
.password(password)
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
System.out.println("Connected to Cloudant : " + user);
//This doesn't works and fire the errror Show the server version
System.out.println("Server Version: " + client.serverVersion());
//This doesn't works and fire the error to. Show databases
System.out.println("Dbs: " + client.getAllDbs());
return client;
} catch (Exception e) {
throw new RuntimeException("Unable to connect", e);
}
And from localhost I have this error:
[ERROR ] Failed to get cookie from server, response code 503, cookie authentication will not be attempted again
[err] java.lang.RuntimeException: Unable to connect to repository
[err] at it.sinesy.nosql.CloudantClientMgr.createClient(CloudantClientMgr.java:110)
[err] at it.sinesy.nosql.CloudantClientMgr.initClient(CloudantClientMgr.java:45)
[err] at it.sinesy.nosql.CloudantClientMgr.getDB(CloudantClientMgr.java:117)
[err] at it.sinesy.nosql.ResourceServlet.getDB(ResourceServlet.java:307)
[err] at it.sinesy.nosql.ResourceServlet.get(ResourceServlet.java:110)
[err] at sun.reflect.GeneratedMethodAccessor751.invoke(Unknown Source)
[err] at java.lang.reflect.Method.invoke(Method.java:498)
[err] at com.ibm.ws.jaxrs20.server.LibertyJaxRsServerFactoryBean.performInvocation(LibertyJaxRsServerFactoryBean.java:646)
[err] at [internal classes]
[err] at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
[err] at com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:96)
[err] at [internal classes]
[err] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[err] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[err] at java.lang.Thread.run(Thread.java:748)
[err] Caused by: com.cloudant.client.org.lightcouch.CouchDbException: 503 Service Unavailable: service_unavailable: Service unavailable
[err] at com.cloudant.client.org.lightcouch.CouchDbClient.execute(CouchDbClient.java:526)
[err] at com.cloudant.client.org.lightcouch.CouchDbClient.executeToInputStream(CouchDbClient.java:574)
[err] at com.cloudant.client.org.lightcouch.CouchDbClient.get(CouchDbClient.java:320)
[err] at com.cloudant.client.org.lightcouch.CouchDbClient.serverVersion(CouchDbClient.java:240)
[err] at com.cloudant.client.api.CloudantClient.serverVersion(CloudantClient.java:272)
[err] at it.sinesy.nosql.CloudantClientMgr.createClient(CloudantClientMgr.java:103)
[err] ... 45 more
I'm not behind a proxy.. What am I doing wrong?