2012-06-28 47 views
10

我正在更新我的應用程序以播放2.0.2。更新播放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的工作是否有一些配置更改?

謝謝。

+0

類似的問題。 – schmmd

+0

初次使用play 2.0.2創建'RemoteServerStarted @ akka://[email protected]:9002'時創建。以前這是'application @ 127.0.0.1'。當任何創建演員的代碼運行時,我會看到「Address already in use」錯誤。 – schmmd

+0

我創建了一個產生此錯誤的示例應用程序。請參閱https://gist.github.com/3063509。 – schmmd

回答

7

也許試試這個:從akka documentation,可以將端口設置爲0,使用自動選擇一個:創建一個使用`concurrent.Akka.future`承諾的時候,這裏

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

我可以用這種方式部署應用程序,但我需要知道端口是從另一個服務器調用我的遠程參與者的端口。 –

+1

快速Google搜索後,似乎可以使用'akka.remote.RemoteActorRefProvider.getExternalAddressFor'(https://groups.google.com/forum/?fromgroups#!topic/akka-user/POngjU9UpK8)。然後,您可以編寫一個控制器,使用http請求從其他服務器獲取此地址。 –

+0

這對我有效。 – schmmd