Couchbase:连接被拒绝

时间:2015-03-30 14:15:34

标签: java couchbase

我尝试连接到Intranet上的Couchbase服务器。为此,我使用Java SDK和以下配置:

CouchbaseEnvironment couchbaseEnvironment = DefaultCouchbaseEnvironment.builder()
                .queryEnabled(true)
                .queryPort(11210)
                .build();

        Cluster cluster = CouchbaseCluster.create(couchbaseEnvironment, "192.168.1.150");
        Bucket bucket = cluster.openBucket("mybucket");

然而,这只会让我在控制台上出现很多错误:

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,也会发生同样的情况。我做错了什么?

2 个答案:

答案 0 :(得分:4)

首先,11210是Key / Value操作协议的保留couchbase端口,因此您不应该尝试将其设置为查询端口(不是同一服务)!

感谢包含日志,它表明SDK正在尝试连接到localhost而不是连接到远程节点。我认为您在使用与Couchbase Server 3.0.1或更低版本一起使用的版本2.1.1中的错误时,我是对的吗?

如果是这样,该bug已经在Java SDK 2.1.2中得到修复,应该在4月初发布。您可以使用开发者预览检查是否属于这种情况(但在发布后不要忘记切换到官方GA版。)

(由于现在已正式推出,因此已删除2.1.2预览版的处理过程)

跟踪错误here

编辑备注:版本2.1.2及其他几个版本已发布,其中包含错误修正

答案 1 :(得分:0)

我遇到此错误,并通过安装benchebase解决了。 我遇到这种情况是因为我在本地计算机上仅安装了ouchdb。