【问题标题】:Akka Cluster Connection Refused Between Machines机器之间的 Akka 集群连接被拒绝
【发布时间】:2020-09-29 23:22:48
【问题描述】:

我正在尝试使用 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 连接?

【问题讨论】:

    标签: scala akka


    【解决方案1】:

    JohanAndren 在 Discuss Lightbend 论坛上回答了我的问题:

    https://discuss.lightbend.com/t/akka-cluster-connection-refused-between-machines/7263

    答案是您不能使用 127.0.0.1 localhost 定义,所有节点都必须使用它们的公共 ips/主机名和端口。

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 1970-01-01
      • 2021-04-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-20
      • 2020-07-08
      • 1970-01-01
      相关资源
      最近更新 更多