Method alive(port)
in RemoteActor
does not take IP address as parameter.
It constructs internally a TcpService
object which assings the IP address by calling Java's InetAddress.getLocalHost().getHostAddress()
which returns the IP of the first available interface.
This is causing problems on machines with multiple network interfaces as it might return the wrong IP address.
Is there any possible way to overcome this issue.
Thanks.
Good question. It depends on how much you want to invest in a solution. I can imagine two ways:
1) The first way to change the default implementation is to write something better yourself. It's not that hard though since all the code for the remote actor library is available on GitHub.
My suggestion would be to re-implement parts of the TcpSerice class, especially line 73 to something like:
This method also allows you to customize other stuff if you'd like to add or change something else.
2) The other (and probably simpler) method would be to avoid using the default implementation all together and instead use the very popular actor-framework akka. Akka provides a great deal of additional features, but also efficiency and robustness. If you look on their GitHub and the Server class, you'll see that the host is actually read from a global config-entry "hostname". A detailed guide on how to manipulate the configs are given here. You should be able to use code similar to the above to find the right interface and address.
Hope that helps!