0
votes

I'm new to akka and wanted to connect two PC using akka remotely just to run some code in both as (2 actors). I had tried the example in akka doc. But what I really do is to add the 2 IP addresses into config file I always get this error?

First machine give me this error:

[info] [ERROR] [11/20/2018 13:58:48.833] [ClusterSystem-akka.remote.default-remote-dispatcher-6] [akka.remote.artery.Association(akka://ClusterSystem)] Outbound control stream to [akka://[email protected]:2552] failed. Restarting it. Handshake with [akka://[email protected]:2552] did not complete within 20000 ms (akka.remote.artery.OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://[email protected]:2552] did not complete within 20000 ms)

And second machine:

Exception in thread "main" akka.remote.RemoteTransportException: Failed to bind TCP to [192.168.1.3:2552] due to: Bind failed because of java.net.BindException: Cannot assign requested address: bind

Config file content :

akka {
  actor {
    provider = cluster
  }
  remote {
    artery {
      enabled = on
      transport = tcp
      canonical.hostname = "192.168.1.3"
      canonical.port = 0
    }
  }
  cluster {
    seed-nodes = [
      "akka://[email protected]:2552",
      "akka://[email protected]:2552"]

    # auto downing is NOT safe for production deployments.
    # you may want to use it during development, read more about it in the docs.
    auto-down-unreachable-after = 120s
  }
}

# Enable metrics extension in akka-cluster-metrics.
akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]

# Sigar native library extract location during tests.
# Note: use per-jvm-instance folder when running multiple jvm on one host.
akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native
1
First of all you need to fix binding problem on the second pc.Aleksey Isachenkov

1 Answers

0
votes

First of all, you don't need to add cluster configuration for AKKA remoting. Both the PCs or nodes should be enabled remoting with a concrete port instead of "0" that way you know which port to connect.

Have below configurations

PC1

akka {
  actor {
    provider = remote
  }
  remote {
    artery {
      enabled = on
      transport = tcp
      canonical.hostname = "192.168.1.3"
      canonical.port = 19000
    }
  }
} 

PC2

akka {
  actor {
    provider = remote
  }
  remote {
    artery {
      enabled = on
      transport = tcp
      canonical.hostname = "192.168.1.4"
      canonical.port = 18000
    }
  }
} 

Use below actor path to connect any actor in remote from PC1 to PC2

akka://<PC2-ActorSystem>@192.168.1.4:18000/user/<actor deployed in PC2>

Use below actor path to connect from PC2 to PC1

akka://<PC2-ActorSystem>@192.168.1.3:19000/user/<actor deployed in PC1>

Port numbers and IP address are samples.