远程连接AKKA中的两台机器,连接被拒绝



我是akka的新手,想用akka远程连接两台电脑,只是为了在两者中运行一些代码(2个参与者(。我在阿卡医生那里试过这个例子。但我真正要做的是将2个IP地址添加到配置文件中,我总是收到这个错误?

第一台机器给我这个错误:

[info][ERROR][11/20/2018 13:58:48.833][ClusterSystem akka.remote.default-remote-dispatcher-6][akka.mote.artery.Association(akka://ClusterSystem)]出站控制流到[akka://ClusterSystem@192.168.1.2:2552]失败。重新启动。与握手[akka://ClusterSystem@192.168.1.2:2552]未在20000毫秒内完成(akka.remote.artnery.OutboundHandshake$HandshakeTimeoutException:与握手[akka://ClusterSystem@192.168.1.2:2552]没有在20000ms内完成(

第二台机器:

线程"main"中出现异常akka.remote.RemoteTransportException:无法将TCP绑定到[1192.168.1.3:2552]由于:绑定失败,因为java.net.BindException:无法分配请求的地址:绑定

配置文件内容:

akka {
actor {
provider = cluster
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.3"
canonical.port = 0
}
}
cluster {
seed-nodes = [
"akka://ClusterSystem@192.168.1.3:2552",
"akka://ClusterSystem@192.168.1.2: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

首先,您不需要为AKKA远程处理添加集群配置。PC或节点都应该使用一个具体的端口而不是"0"来启用远程处理,这样你就知道要连接哪个端口。

具有以下配置

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

使用以下行动者路径将PC1远程中的任何行动者连接到PC2

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

使用下面的actor路径从PC2连接到PC1

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

端口号和IP地址是示例。

最新更新