11

我正在将我的应用程序更新为 play-2.0.2。

部署 Akka 远程参与者时遇到问题:

[error] p.c.ActionInvoker - Failed to bind to: /127.0.0.1:2552
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.0.1:2552
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298) ~[netty.jar:na]
    at akka.remote.netty.NettyRemoteServer.start(Server.scala:53) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.remote.netty.NettyRemoteTransport.start(NettyRemoteSupport.scala:73) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:95) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.actor.ActorSystemImpl._start(ActorSystem.scala:568) ~[akka-actor.jar:2.0.2]
    at akka.actor.ActorSystemImpl.start(ActorSystem.scala:575) ~[akka-actor.jar:2.0.2]
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind(Native Method) ~[na:1.6.0_33]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126) ~[na:1.6.0_33]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) ~[na:1.6.0_33]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:140) ~[netty.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:92) ~[netty.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66) ~[netty.jar:na]
[error] a.r.RouterConfig$$anon$1 - Failed to bind to: /127.0.0.1:2552
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.0.1:2552
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298) ~[netty.jar:na]
    at akka.remote.netty.NettyRemoteServer.start(Server.scala:53) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.remote.netty.NettyRemoteTransport.start(NettyRemoteSupport.scala:73) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:95) ~[akka-remote-2.0.2.jar:2.0.2]
    at akka.actor.ActorSystemImpl._start(ActorSystem.scala:568) ~[akka-actor.jar:2.0.2]
    at akka.actor.ActorSystemImpl.start(ActorSystem.scala:575) ~[akka-actor.jar:2.0.2]
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind(Native Method) ~[na:1.6.0_33]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126) ~[na:1.6.0_33]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) ~[na:1.6.0_33]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:140) ~[netty.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:92) ~[netty.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66) ~[netty.jar:na]
[error] play - Cannot invoke the action, eventually got an error: Thrown(akka.pattern.AskTimeoutException: Timed out)

在应用程序启动时调用以下代码时:

ActorSystem system = Akka.system();

Address addr = new Address("akka", "application");
defaultInstance = system.actorOf(new Props(TheActor.class).withDeploy(new Deploy(new RemoteScope(addr))), "theActor");

在 application.conf 中进行此配置时:

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 2552
    }
 }
}

相同的设置在 play-2.0.1 上运行良好。

在 play-2.0.2 上是否有一些配置更改?

谢谢你。

4

1 回答 1

7

也许试试这个:从akka 文档中,您可以将端口设置为 0 以使用自动选择的端口:

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 0
    }
 }
}
于 2012-07-15T14:22:11.503 回答