机器之间的Akka群集连接被拒绝

vm0i2vca  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(219)

我尝试使用Akka Clustering创建一个项目,并且一直使用Lightbend(https://github.com/akka/akka-samples/tree/2.6/akka-sample-cluster-scala)的akka-cluster-sample-scala作为基础。由于它缺少很多关于通过网络连接的直接信息,我修改了application.conf,使其看起来更像这样:

akka {
  actor {
    provider = cluster

    serialization-bindings {
      "sample.cluster.CborSerializable" = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = "127.0.0.1"
      canonical.port = 0
    }
  }
  cluster {
    seed-nodes = [
      "akka://ClusterSystem@131.194.71.132:25251",
      "akka://ClusterSystem@131.194.71.132:25252",
      "akka://ClusterSystem@131.194.71.133:25251",
      "akka://ClusterSystem@131.194.71.133:25252"]
    downing-provider-class = "akka.cluster.sbr.SplitBrainResolverProvider"
  }
}

当在这两台机器上运行时,Akka无法通过TCP在它们之间进行连接,从而导致以下警告:

[info] [2020-09-28 14:34:37,877] [WARN] [akka.stream.Materializer] [] [ClusterSystem-akka.actor.default-dispatcher-5] - [outbound connection to [akka://ClusterSystem@131.194.71.132:25251], control stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(131.194.71.132:25251,None,List(),Some(5000 milliseconds),true)] failed because of java.net.ConnectException: Connection refused

是否有任何明显的错误可能导致此问题,或者需要重新配置一些更具体的问题,以便允许这些计算机之间通过TCP进行连接?

r7xajy2e

r7xajy2e1#

我的问题是由JohanAndren在讨论弯光论坛上回答的:
https://discuss.lightbend.com/t/akka-cluster-connection-refused-between-machines/7263
答案是,您不能使用127.0.0.1 localhost定义,所有节点都必须使用它们的公共ip/主机名和端口。

相关问题