我有以下类创建一个actor系统并在代码中将该配置作为字符串提供。但是,我得到的例外是netty无法在默认主机和端口上启动 - 当我向配置提供不同的值时
class RemoteActorSystemCreator extends ActorSystemCreator {
def create(name: String, hostName: String, port: String) = {
val string: Config = ConfigFactory.parseString(
s"""akka {
actor {
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "$hostName"
port = $port
}
}
}"""
)
ActorSystem.create(name, ConfigFactory.load(string))
}
}
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.1.1:2552
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298)
at akka.remote.netty.NettyRemoteServer.start(Server.scala:51)
at akka.remote.netty.NettyRemoteTransport.start(NettyRemoteSupport.scala:181)
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.1.1:2552
答案 0 :(得分:7)
您使用的是Akka 2.1.x版,但配置为2.2格式。
对于2.1.4,端口的配置属性为akka.remote.netty.port
。