简体   繁体   English

在Scala中使用Java API查询Couchbase中的视图会引发超时异常

[英]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. 编辑:请注意,这在Java 1.6中可正常使用,但在Java 1.7中将失败。

I've been struggling to get the Couchbase 2.0 java API to work with views. 我一直在努力使Couchbase 2.0 Java API与视图一起使用。 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: 当我使用Java 1.7运行以下scala代码时,出现以下异常:

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: 但是,下面的python代码可以完美地工作,连接到视图并具有正确的输出:

    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. 不幸的是,对于该项目,不能使用python。

we are aware of this issue (http://www.couchbase.com/issues/browse/JCBC-151). 我们知道此问题(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. 这不是您的错或scalas,仅是我们的客户端当前在连接java 7时遇到了一些问题。如果此问题已解决,我确定您的代码将按预期运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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