Reputation: 1313
I have two physical different machines (192.168.1.37 and 192.168.1.99), I can ping easily each machine from the other one. I'm trying to connect them with Akka remote (I'm using Java)
My local machine (trying to send a message to an actor on the remote one) :
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.37"
canonical.port = 2556
}
}
}
And the code :
ActorSystem system = ActorSystem.create("local", ConfigFactory.load("akka.conf"));
ActorSelection selection = system.actorSelection("akka://[email protected]:2555/user/actor");
selection.tell("trying to connect...", ActorRef.noSender());
Now the config for my remote machine (I started it before launching local one) :
akka {
actor {
provider = remote
}
remote {
artery {
enabled = on
transport = tcp
canonical.hostname = "192.168.1.99"
canonical.port = 2555
}
}
}
And the code :
ActorSystem system = ActorSystem.create("remote", ConfigFactory.load("akka.conf"));
ActorRef actor = system.actorOf(Props.create(SimpleActor.class),"actor");
Then I run the remote JVM and start the local one after. Here are the logs I got for the local one :
[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://[email protected]: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://[email protected]: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://[email protected]: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://[email protected]: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://[email protected]: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://[email protected]: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://[email protected]:2555], control stream] Upstream failed, cause: OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://[email protected]: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://[email protected]:2555] failed. Restarting it. Handshake with [akka://[email protected]:2555] did not complete within 20000 ms (akka.remote.artery.OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://[email protected]: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://[email protected]:2555] failed. Restarting it. Handshake with [akka://[email protected]:2555] did not complete within 20000 ms (akka.remote.artery.OutboundHandshake$HandshakeTimeoutException: Handshake with [akka://[email protected]:2555] did not complete within 20000 ms)
Upvotes: 2
Views: 1654
Reputation: 7633
Your example looks fine. I have one that does the same thing for 2 JVM but in the same machine. The first thing thaat I recommend is to test everything in only one machine but different JVMs. If it works then you got to 2 machines. Here I suggest to check the ports first because pinging does not uses TCP. Check this question: https://networkengineering.stackexchange.com/a/37897/72199
The standard ping command does not use TCP or UDP. It uses ICMP. To be more precise ICMP type 8 (echo message) and type 0 (echo reply message) are used. ICMP has no ports!
See RFC792 for further details.
My suggestion is that you can test the specific port using telnet:
Open a command prompt Type in "telnet " on each machine For example, we would type “telnet 192.168.1.99 2555" from 192.168.1.37 and vice versa. If a blank screen appears then the port is open, and the test is successful. If you receive a connecting... message or an error message then something is blocking that port.
Besides that, using akka cluster is easier...
Upvotes: 2