Hi all,
I am running the Java SDK from my Windows machine and trying to add/fetch JSON data from the Couchbase server which is on a Ubuntu 14.04 on a Google Compute Engine VM.
(Earlier I was getting an error for Timeout in which I could not create the bucket. After going through the forum I modified my code to create a custom Couchbase cluster and now I am able to create the bucket object.)
But now I am getting an exception.
Following is my code:
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
//this set the IO socket timeout globally, to 45s
.socketConnectTimeout((int) TimeUnit.SECONDS.toMillis(45))
//this sets the connection timeout for openBucket calls globally (unless a particular call provides its own timeout)
.connectTimeout(TimeUnit.SECONDS.toMillis(60))
.build();
Cluster cluster = CouchbaseCluster.create(env,“104.155.176.50”,“107.167.190.181”);
Bucket bucket = cluster.openBucket(“hello_me”);//bucket.get("21st_amendment_brewery_cafe-21a_ipa").content().get("name"); JsonDocument doc = JsonDocument.create("temp_ani", JsonObject.create().put("some", "value")); System.out.println(bucket.insert(doc));
and following is the stack trace:
INFO: Opened bucket hello_me
Sep 12, 2016 4:48:27 PM com.couchbase.client.core.node.CouchbaseNode signalDisconnected
INFO: Disconnected from Node 50.176.155.104.bc.googleusercontent.com
Sep 12, 2016 4:48:27 PM com.couchbase.client.core.node.CouchbaseNode signalDisconnected
INFO: Disconnected from Node 181.190.167.107.bc.googleusercontent.com
Exception in thread “main” java.lang.RuntimeException: java.util.concurrent.TimeoutException
at com.couchbase.client.java.util.Blocking.blockForSingle(Blocking.java:71)
at com.couchbase.client.java.CouchbaseBucket.insert(CouchbaseBucket.java:312)
at com.couchbase.client.java.CouchbaseBucket.insert(CouchbaseBucket.java:307)
at com.kpit.ani.springdataCouchbase.App.main(App.java:46)
Caused by: java.util.concurrent.TimeoutException
… 4 more
The exception occurs when I try to run
System.out.println(bucket.insert(doc));
i.e. while inserting the data. What am I doing wrong?
Kindly suggest.
Note: There are two nodes for the cluster and I have provided access to the ports through the GCE firewall. I am novice to Couchbase, any help provided will be appreciated.