问题描述
我尝试连接到Intranet上的Couchbase服务器.为此,我使用Java SDK和以下配置:
I try to connect to a Couchbase server on the intranet. For this purpose, I use the Java SDK and the following configuration:
CouchbaseEnvironment couchbaseEnvironment = DefaultCouchbaseEnvironment.builder()
.queryEnabled(true)
.queryPort(11210)
.build();
Cluster cluster = CouchbaseCluster.create(couchbaseEnvironment, "192.168.1.150");
Bucket bucket = cluster.openBucket("mybucket");
但是,这在控制台上给我留下了很多错误:
However, this just leaves me with lots of errors on the console:
INFO [2015-03-30 14:03:07,306] org.eclipse.jetty.util.log: Logging initialized @1805ms
INFO [2015-03-30 14:03:07,605] com.couchbase.client.core.CouchbaseCore: CoreEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslKeystorePassword='null', queryEnabled=true, queryPort=11210, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=4, computationPoolSize=4, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=1, queryServiceEndpoints=1, ioPool=NioEventLoopGroup, coreScheduler=CoreScheduler, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.1.1 (git: 2.1.1), dcpEnabled=false, retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=com.couchbase.client.core.time.ExponentialDelay@11bd803, reconnectDelay=com.couchbase.client.core.time.ExponentialDelay@58f07f02, observeIntervalDelay=com.couchbase.client.core.time.ExponentialDelay@75798d03, keepAliveInterval=30000, autoreleaseAfter=2000}
INFO [2015-03-30 14:03:16,004] com.couchbase.client.core.node.Node: Connected to Node 192.168.1.150
INFO [2015-03-30 14:03:16,367] com.couchbase.client.core.config.ConfigurationProvider: Opened bucket sortimo_shadow
WARN [2015-03-30 14:03:16,386] com.couchbase.client.core.endpoint.Endpoint: [null][KeyValueEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS:
! java.net.ConnectException: Connection refused: localhost/127.0.0.1:11210
! at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_31]
! at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716) ~[na:1.8.0_31]
! at com.couchbase.client.deps.io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:208) ~[core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:281) ~[core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) [core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [core-io-1.1.1.jar:1.1.1]
! at com.couchbase.client.deps.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [core-io-1.1.1.jar:1.1.1]
! at java.lang.Thread.run(Thread.java:745) [na:1.8.0_31]
INFO [2015-03-30 14:03:16,390] com.couchbase.client.core.node.Node: Disconnected from Node 192.168.1.150
WARN [2015-03-30 14:03:16,402] com.couchbase.client.core.endpoint.Endpoint: [null][ViewEndpoint]: Could not connect to endpoint, retrying with delay 32 MILLISECONDS:
...
如果我选择端口8092而不是11210,也会发生同样的情况.我在做什么错了?
The same happens if I choose port 8092 instead of 11210. What am I doing wrong?
推荐答案
首先,11210是键/值操作协议的保留长沙发端口,因此您不应尝试将其设置为查询端口(而不是将其设置为查询端口).相同的服务)!
First off, 11210 is a reserved couchbase port for the Key/Value operations protocol, so you shouldn't try to set it as the query port (not the same service)!
感谢包括日志,它表明SDK尝试连接到localhost而不是连接到远程节点.我认为您遇到的是与Couchbase Server 3.0.1或更低版本结合使用的2.1.1版本中的错误,对吗?
Thanks for including logs, it shows that the SDK is trying to connect to localhost instead of connecting to the remote node. I think you're hitting a bug in version 2.1.1 used in conjunction with Couchbase Server 3.0.1 or lesser, am I right?
如果是,则该错误已在Java SDK 2.1.2中修复,该错误应在4月初发布.您可以使用开发人员预览版检查情况是否如此(但发布后请不要忘记切换到正式的GA版本).
If so, the bug has been fixed in Java SDK 2.1.2, which should be released beginning of April. You can check that this is the case by using the Developer Preview (but don't forget to switch to official GA version once it is released).
(由于现在已正式提供,因此删除了2.1.2预览版的过程)
编辑说明:2.1.2版和自发行以来的其他几个版本包括错误修正
edit note: versions 2.1.2 and several additional versions have since been released that include the bugfix
这篇关于Couchbase:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!