警告 i.v.c.e.i.clustered.ConnectionHolder 失败

WARN i.v.c.e.i.clustered.ConnectionHolder failed

我收到一条错误消息:

10:29:56.116 [vert.x-worker-thread-18] WARN  i.v.c.e.i.clustered.ConnectionHolder - Connecting to server localhost:53990 failed

我找到了讨论:https://groups.google.com/forum/#!topic/vertx/bws3x9-WsV0 其中一个回复是:

你是怎么开始的Vert.x? CLI 和 Launcher class 中有一个主机名检测机制。 如果你有自己的 main class,请确保正确设置 ClusterHost 选项。

所以我在https://vertx.io/docs/vertx-hazelcast/java/

中寻找描述

其中说:

当 运行ning Vert.x 处于集群模式时,您还应该确保 Vert.x 知道正确的接口。当在命令行中 运行ning 时,这是通过指定 cluster-host 选项来完成的: vertx 运行 myverticle.js -cluster -cluster-host 你的IP地址 其中 your-ip-address 与您在 Hazelcast 配置中指定的 IP 地址相同。 如果以编程方式使用 Vert.x,您可以使用 setClusterHost.

指定它

我不明白这一点,因为我假设 localhost 就可以了。我只是在尝试双节点配置,请参阅 https://github.com/rc-dukes/dukes/issues/19

需要什么来理解和解决这个问题?

https://github.com/vert-x3/vertx-maven-starter/issues/6

展示另一个初学者可能会把事情搞砸的场景。 我该如何调试这个

日志输出显示涉及的两个 vert.x 客户端确实已通过 Multicast Joiner 正确连接(x.y.z 隐藏了真实 ip):

08:42:09.539 [hz._hzInstance_1_dev.priority-generic-operation.thread-0] INFO  c.h.internal.cluster.ClusterService - [x.y.z.82]:5701 [dev] [3.12.5] 

Members {size:2, ver:8} [
    Member [x.y.z.82]:5701 - 29b35836-aad1-4314-af62-c453ce200ffa this
    Member [x.y.z.25]:5701 - f67995b7-f47e-4037-b7a4-fcedeff4fc91
]

其中一个客户端是 raspberry PI,默认情况下它用 127.0.0.1 host address 标识自己。

删除 /etc/hosts 中的条目并用具有完整 IP 地址的正确条目替换它是第一个必要步骤。

cat /etc/hosts
127.0.0.1   localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

# on the main network
x.y.z.82 picarford.bitplan.com picarford

然后主机名需要用作所有成员的host/clusterhost。

hostname=InetAddress.getLocalHost().getCanonicalHostName()
starter.setClusterHost(hostname,hostname)

ClusterStarter.java

   /**
   * prepare the starter
   */
  public void prepare() {
    if (!prepared) {
      Config.configureLogging();
      try {
        setHostname(InetAddress.getLocalHost().getCanonicalHostName());
      } catch (UnknownHostException e) {
        LOG.error(e.getMessage());
      }
      prepared = true;
    }
  }

  private String hostname;

  /**
   * configure the cluster
   * @param clusterHostname
   * @param publicHost
   */
  public void configureCluster(String clusterHostname,String publicHost) {
    if (clusterHostname == null) {
      clusterHostname=getHostname();
    }
    if (publicHost==null) {
      publicHost=getHostname();
    }
    String msg=String.format("starting cluster on %s setting host to %s and clusterPublicHost to %s",getHostname(),clusterHostname,publicHost);
    LOG.info(msg);
    EventBusOptions eventBusOptions = getOptions().getEventBusOptions();
    // https://github.com/eclipse-vertx/vert.x/issues/3229
    // 
    // https://vertx.io/docs/apidocs/io/vertx/core/eventbus/EventBusOptions.html#setClusterPublicHost-java.lang.String-
    eventBusOptions.setHost(clusterHostname);
    eventBusOptions.setClusterPublicHost(publicHost);
  }