1

我有以下类,它创建一个演员系统并将配置作为代码中的字符串提供。但是,我得到了 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
4

1 回答 1

7

您使用的是 Akka 版本 2.1.x,但配置是 2.2 格式。对于 2.1.4,端口的配置属性是akka.remote.netty.port.

于 2013-06-14T20:11:45.703 回答