I want to build an actor system that has a common server at a static IP address and port. There will be many clients that know the server’s address. The server doesn’t know the IP addresses of the clients.
Configuration of the server:
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
hostname = "46.38.232.161"
port = 2552
}
}
}
Configuration of the client:
akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
transport = "akka.remote.netty.NettyRemoteTransport"
netty {
port = 2553
}
}
}
A client may come from the entire internet. Now I want to send messages from actors on the client to actors on the server. How does the server know, where to send back his messages? When I send ActorPaths to the server, so he would know the corresponding client’s address, these don’t contain the client’s IP address.
akka.remote.netty.hostnameproperty may be set inside yourapplication.conf, to a reachable IP address or resolvable name, in a case you want to communicate across the network. Actually your “client” nodes will also be a servers, when using Akka.In a case if address is unknown at app start, consider this code fragment from Akka documentation: