So I am trying to start 2 instances of an Akka app on my local machine (in separate JVMs).
When instance #1 starts isSeedNode = true (so port is bound to 2552)
When instance #2 starts isSeedNode = false (so port should bind to 9999)
Instance #1 starts fine, but when instance #2 starts, I get the exceptions below, which indicate it is not obeying my port settings...? What am I doing wrong
boolean isSeedNode = true;
Config remotingConf = ConfigFactory.parseString(
" remote {"+
" enabled-transports = [\"akka.remote.netty.tcp\"]\n"+
" netty.tcp {"+
" hostname = \"192.168.0.208\"\n"+
" port = "+ (isSeedNode ? 2552 : 9999)+"\n"+
" bind-port = "+ (isSeedNode ? 2552 : 9999)+"\n"+
" }"+
" }");
Config combined = remotingConf.withFallback(appConfConfig);
system = ActorSystem.create(name,ConfigFactory.load(combined));
My application.conf
akka {
actor {
provider = "akka.cluster.ClusterActorRefProvider"
debug {
autoreceive = on
lifecycle = on
unhandled = on
}
}
}
EXCEPTION thrown from instance #2 (when instance #1 is already running)
Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /192.168.0.208:2552 Caused by: java.net.BindException: Address already in use
Issue was that instead of "remote" I had to specify "akka.remote". Then it all worked