【发布时间】:2020-10-26 21:39:03
【问题描述】:
我有两台不同的物理机器(192.168.1.37 和 192.168.1.99),我可以很容易地从另一台机器上 ping 每一台机器。 我正在尝试将它们与 Akka 远程连接(我正在使用 Java)
我的本地机器(试图向远程机器上的演员发送消息):
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.37"
canonical.port = 2556
}
}
}
还有代码:
ActorSystem system = ActorSystem.create("local", ConfigFactory.load("akka.conf"));
ActorSelection selection = system.actorSelection("akka://remote@192.168.1.99:2555/user/actor");
selection.tell("trying to connect...", ActorRef.noSender());
现在我的远程机器的配置(我在启动本地机器之前启动它):
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.99"
canonical.port = 2555
}
}
}
还有代码:
ActorSystem system = ActorSystem.create("remote", ConfigFactory.load("akka.conf"));
ActorRef actor = system.actorOf(Props.create(SimpleActor.class),"actor");
然后我运行远程 JVM,然后启动本地 JVM。这是我为本地日志获取的日志:
[INFO] [07/06/2020 19:42:06.950] [main] [akka.remote.artery.tcp.ArteryTcpTransport(akka://local)] Remoting started with transport [Artery tcp]; listening on address [akka://local@192.168.1.37:2556] with UID [-6291059934924481437]
[WARN] [07/06/2020 19:42:12.653] [local-akka.remote.default-remote-dispatcher-7] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], message stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired
[WARN] [07/06/2020 19:42:12.653] [local-akka.remote.default-remote-dispatcher-4] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], control stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired
[WARN] [07/06/2020 19:42:12.655] [local-akka.remote.default-remote-dispatcher-4] [RestartWithBackoffFlow(akka://local)] Restarting graph due to failure. stack_trace: (akka.stream.StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired)
[WARN] [07/06/2020 19:42:12.655] [local-akka.remote.default-remote-dispatcher-7] [RestartWithBackoffFlow(akka://local)] Restarting graph due to failure. stack_trace: (akka.stream.StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired)
[WARN] [07/06/2020 19:42:19.349] [local-akka.remote.default-remote-dispatcher-7] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], message stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired
[WARN] [07/06/2020 19:42:19.350] [local-akka.remote.default-remote-dispatcher-7] [RestartWithBackoffFlow(akka://local)] Restarting graph due to failure. stack_trace: (akka.stream.StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired)
[WARN] [07/06/2020 19:42:20.346] [local-akka.remote.default-remote-dispatcher-7] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], control stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired
[WARN] [07/06/2020 19:42:20.346] [local-akka.remote.default-remote-dispatcher-7] [RestartWithBackoffFlow(akka://local)] Restarting graph due to failure. stack_trace: (akka.stream.StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired)
[WARN] [07/06/2020 19:42:26.365] [local-akka.remote.default-remote-dispatcher-4] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], message stream] Upstream failed, cause: StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired
[WARN] [07/06/2020 19:42:26.366] [local-akka.remote.default-remote-dispatcher-4] [RestartWithBackoffFlow(akka://local)] Restarting graph due to failure. stack_trace: (akka.stream.StreamTcpException: Tcp command [Connect(192.168.1.99/<unresolved>:2555,None,List(),Some(5000 milliseconds),true)] failed because of akka.io.TcpOutgoingConnection$$anon$2: Connect timeout of Some(5000 milliseconds) expired)
[WARN] [07/06/2020 19:42:27.331] [local-akka.remote.default-remote-dispatcher-7] [akka.stream.Log(akka://local/system/StreamSupervisor-0)] [outbound connection to [akka://remote@192.168.1.99:2555], control stream] Upstream failed, cause: OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://remote@192.168.1.99:2555] did not complete within 20000 ms
[INFO] [07/06/2020 19:42:27.335] [local-akka.actor.default-dispatcher-3] [akka://local/deadLetters] Message [java.lang.String] without sender to Actor[akka://local/deadLetters] was not delivered. [1] dead letters encountered. If this is not an expected behavior, then [Actor[akka://local/deadLetters]] may have terminated unexpectedly, This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[ERROR] [07/06/2020 19:42:27.342] [local-akka.remote.default-remote-dispatcher-7] [akka.remote.artery.Association(akka://local)] Outbound message stream to [akka://remote@192.168.1.99:2555] failed. Restarting it. Handshake with [akka://remote@192.168.1.99:2555] did not complete within 20000 ms (akka.remote.artery.OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://remote@192.168.1.99:2555] did not complete within 20000 ms)
[ERROR] [07/06/2020 19:42:27.348] [local-akka.remote.default-remote-dispatcher-7] [akka.remote.artery.Association(akka://local)] Outbound control stream to [akka://remote@192.168.1.99:2555] failed. Restarting it. Handshake with [akka://remote@192.168.1.99:2555] did not complete within 20000 ms (akka.remote.artery.OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://remote@192.168.1.99:2555] did not complete within 20000 ms)
【问题讨论】:
-
我建议使用 akka-cluster,或者在你的服务节点上创建一个 akka-http 或 akka-grpc 服务,以便与其他服务进行通信,而不是使用 akka 远程处理本身。经典的 akka 远程处理已被弃用。请参阅文档中此页面顶部的建议。 doc.akka.io/docs/akka/current/remoting-artery.html
标签: scala akka akka-cluster