我的设置:一个Hazelcast docker container在boot2docker vm中运行(托管在Windows上,是的,端口5701被转发)。 这是Hazelcast 3.4.2。
当我尝试将一个简单的java客户端连接到这个hazelcast实例时,我得到了一个:
avr. 01, 2015 10:52:03 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is STARTING
avr. 01, 2015 10:52:04 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is STARTED
avr. 01, 2015 10:52:06 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is CLIENT_CONNECTED
avr. 01, 2015 10:52:06 PM com.hazelcast.client.spi.impl.ClusterListenerThread
INFOS:
Members [1] {
Member [172.17.42.1]:5701
}
avr. 01, 2015 10:53:46 PM com.hazelcast.client.spi.ClientPartitionService
GRAVE: Error while fetching cluster partition table!
java.io.IOException: java.util.concurrent.TimeoutException
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(Cli entConnectionManagerImpl.java:337)
...
Exception in thread "main" java.lang.IllegalStateException: Cannot get initial partitions!
at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getInitialPartitions(ClientPartitionServiceImpl.java:89)
at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.start(ClientPartitionServiceImpl.java:65)
at com.hazelcast.client.impl.HazelcastClientInstanceImpl.start(HazelcastClientInstanceImpl.java:189)
at ...
avr. 01, 2015 10:56:35 PM com.hazelcast.client.spi.impl.ClusterListenerThread
AVERTISSEMENT: Error while listening cluster events! -> ClientConnection{live=true, writeHandler=com.hazelcast.client.connection.nio.ClientWriteHandler@3a2f22ed, readHandler=com.hazelcast.client.connection.nio.ClientReadHandler@6b7cdede, connectionId=1, socketChannel=DefaultSocketChannelWrapper{socketChannel=java.nio.channels.SocketChannel[connected local=/127.0.0.1:64753 remote=/127.0.0.1:5701]}, remoteEndpoint=Address[172.17.42.1]:5701}, Error: java.io.EOFException: Remote socket closed!
avr. 01, 2015 10:56:35 PM com.hazelcast.client.connection.nio.ClientConnection
AVERTISSEMENT: Connection [null] lost. Reason: Socket explicitly closed
avr. 01, 2015 10:56:35 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is CLIENT_DISCONNECTED
avr. 01, 2015 10:56:43 PM com.hazelcast.client.spi.impl.ClusterListenerThread
AVERTISSEMENT: Unable to get alive cluster connection, try in 0 ms later, attempt 1 of 2.
avr. 01, 2015 10:56:50 PM com.hazelcast.client.spi.impl.ClusterListenerThread
AVERTISSEMENT: Unable to get alive cluster connection, try in 0 ms later, attempt 2 of 2.
avr. 01, 2015 10:56:50 PM com.hazelcast.client.spi.impl.ClusterListenerThread
GRAVE: Error while connecting to cluster!
java.lang.IllegalStateException: Unable to connect to any address in the config! The following addresses were tried:[/127.0.0.1:5701, /172.17.42.1:5701, /127.0.0.1:5702, /127.0.0.1:5703]
at com.hazelcast.client.spi.impl.ClusterListenerThread.connectToOne(ClusterListenerThread.java:286)
at com.hazelcast.client.spi.impl.ClusterListenerThread.run(ClusterListenerThread.java:89)
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:111)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:386)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:353)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:57)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
avr. 01, 2015 10:56:50 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is SHUTTING_DOWN
avr. 01, 2015 10:56:50 PM com.hazelcast.core.LifecycleService
INFOS: HazelcastClient[hz.client_0_test][3.4.2] is SHUTDOWN
总结一下:客户端似乎看到了集群及其成员,但接下来会发生一些阻止连接按预期工作的事情。
有什么想法吗?
答案 0 :(得分:0)
我想您的问题是,Hazelcast节点的内部和外部地址是不同的,即使可以通过NAT到达节点,也拒绝接收公共地址的请求。 您可以使用配置来配置公共地址:http://docs.hazelcast.org/docs/3.4/manual/html-single/hazelcast-documentation.html#public-address(参见上面的示例)。