简体   繁体   English

使用 java 客户端连接到在备用端口上运行的 couchbase

[英]Connecting to couchbase running on alternate ports using java client

I'm using couchbase-client 2.3.2 for Java and Couchbase server Community 4.0我使用 couchbase-client 2.3.2 for Java 和 Couchbase server Community 4.0

So I'm experimenting with running Couchbase on non-standard ports using the documentation at Couchbase website所以我正在尝试使用Couchbase 网站上的文档在非标准端口上运行 Couchbase

I've managed to start Couchbase using these alternate ports but I've only managed to change some of the ports in the java client, here's my code:我设法使用这些备用端口启动了 Couchbase,但我只设法更改了 java 客户端中的一些端口,这是我的代码:

        final CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
            .bootstrapCarrierDirectPort(21210)
            .bootstrapHttpDirectPort(9091)
            .build();
    return CouchbaseCluster.create(env, "10.0.2.15");

My program is able to connect to couchbase and so some things, however I still need to change the view port (default 8092) and the query port (default 8093) in the client.我的程序能够连接到 couchbase 等等,但是我仍然需要更改客户端中的查看端口(默认 8092)和查询端口(默认 8093)。 as a result I'm met with these errors:结果我遇到了这些错误:

2016-09-30 14:03:49.696 [] WARN cccceEndpoint - [null][QueryEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS: ! 2016-09-30 14:03:49.696 [] WARN cccceEndpoint - [null][QueryEndpoint]:无法连接到端点,重试延迟 32 毫秒:! java.net.ConnectException: Connection refused: /10.0.2.15:8093 java.net.ConnectException:连接被拒绝:/10.0.2.15:8093

2016-09-30 14:03:52.077 [] WARN cccceEndpoint - [null][ViewEndpoint]: Could not connect to endpoint, retrying with delay 2048 MILLISECONDS: ! 2016-09-30 14:03:52.077 [] WARN cccceEndpoint - [null][ViewEndpoint]:无法连接到端点,重试延迟 2048 毫秒:! java.net.ConnectException: Connection refused: /10.0.2.15:8092 java.net.ConnectException:连接被拒绝:/10.0.2.15:8092

So the client still tries to connect to 8092 and 8093 when in fact I've changed those to 9092 and 9093所以客户端仍然尝试连接到 8092 和 8093,而实际上我已经将它们更改为 9092 和 9093

From the JavaDoc on 2.3.4 ( http://docs.couchbase.com/sdk-api/couchbase-java-client-2.3.4/ ), I believe what you want is this:从 2.3.4 上的 JavaDoc( http://docs.couchbase.com/sdk-api/couchbase-java-client-2.3.4/ ),我相信你想要的是这个:

DefaultCouchbaseEnvironment.Builder viewEndpoints(int viewServiceEndpoints) DefaultCouchbaseEnvironment.Builder viewEndpoints(int viewServiceEndpoints)

Even though it's completely undocumented, you need to add those ports to static_config as well:即使它完全没有记录,您也需要将这些端口添加到 static_config 中:

{capi_port, 9092}.
{query_port, 9093}.

and then it works, hope someone at couchbase sees this and updates their documentation :)然后它就可以工作了,希望 couchbase 的人看到这个并更新他们的文档:)

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

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