Akka Cluster Connection Refused Between Machines

I am crossposting this issue between here and StackOverflow (https://stackoverflow.com/questions/64108688/akka-cluster-connection-refused-between-machines) since this is specific to Akka.

I am attempting to make a project using Akka Clustering, and have been using the akka-cluster-sample-scala from Lightbend(https://github.com/akka/akka-samples/tree/2.6/akka-sample-cluster-scala) as a base. As it lacks much direct information on connecting across a network, I modified the application.conf to look more like this:

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"
  }
}

When run across these two machines, Akka fails to be able to connect over TCP between them, leading to the following warnings:

[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

Is there anything notably wrong that may be causing this, or something more specifically needing to be reconfigured in order to allow connection over TCP between these machines?

canonical.hostname cannot be 127.0.0.1 and port 0 but must be configured to be the public ip/hostname and port that other nodes can use to reach the node.

So for 131.194.71.132:25251 it needs to be 131.194.71.132 and 25251 for example.

2 Likes

Thank you so much for taking the time to respond. This just helped immensely.