简体   繁体   中英

Using Java API in Scala to query views in Couchbase throws timeout exception

EDIT: Note that this works perfectly in java 1.6 but fails in java 1.7.

I've been struggling to get the Couchbase 2.0 java API to work with views. It works perfectly for getting and putting keys into a bucket.

When I run the scala code below using Java 1.7, I get the following exception:

scala> ERROR com.couchbase.client.ViewNode$EventLogger:  Connection timed out: [localhost/127.0.0.1:8092(closed)]

I've also tried setting the timeout in the connection builder to no avail.

    import java.net.URI
    import com.couchbase.client.CouchbaseClient
    import scala.collection.JavaConversions._
    val uris = List(URI.create("http://127.0.0.1:8091/pools"))
    val client = new CouchbaseClient(uris, "test", "")
    val view = client.asyncGetView("date", "dates")

However, the python code below works perfectly, connects to the view, and has the right output:

    from couchbase.client import Couchbase
    client = Couchbase("localhost:8091", "username", "password")
    bucket = client["test"]
    view = bucket.view("_design/date/_view/dates")
    count = 0
    for row in view:
        count = count + 1
    print(count)

Any ideas how to properly connect? I've tried to copy their examples exactly in my code. Unfortunately using python is not an option for this project.

we are aware of this issue (http://www.couchbase.com/issues/browse/JCBC-151).

It's not your fault or scalas, its just that our client currently has some problems to connect with java 7. If this is fixed, I'm sure your code will work as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM