如何远程启动Akka演员:akka-in-action \ chapter-remoting

时间:2016-04-17 05:51:23

标签: akka actor remoting

通过关注Akka文档,我可以在同一台机器上启动两个演员(前端和后端),他们可以互相交谈。但是,当我尝试将后端actor部署到另一台机器(Linux)时,我遇到了启动远程处理的错误:

============ 检测到多个主要类,选择一个运行:

 [1] com.goticks.BackendMain  
 [2] com.goticks.BackendRemoteDeployMain  
 [3] com.goticks.FrontendMain  
 [4] com.goticks.FrontendRemoteDeployMain  
 [5] com.goticks.FrontendRemoteDeployWatchMain  
 [6] com.goticks.SingleNodeMain  

输入数字:2

[info] Running com.goticks.BackendRemoteDeployMain  
INFO  [Slf4jLogger]: Slf4jLogger started  
INFO  [Remoting]: Starting remoting  

ERROR [NettyTransport]:未能绑定到/192.168.1.9:2551,关闭Netty传输

192.168.1.9是另一台机器。

在backend.conf中:

remote {
  enabled-transports = ["akka.remote.netty.tcp"]  
  netty.tcp {  
    #hostname = "0.0.0.0"  
    hostname = "192.168.1.9"  
    port = 2551  
  }  
}  

我有一个基本问题,当在远程JVM上部署和启动远程actor时,我们是否需要用户登录信息到远程机器?

谢谢,

2 个答案:

答案 0 :(得分:0)

您不需要用户登录信息,我认为您的端口2551已经在hostname = 192.168.1.9上使用,您确定过去没有使用它吗?

我也有同样的问题,我不小心忘了在同一个端口上关闭正在运行的程序,之后我尝试第二次运行该程序,它发生了Exception in thread "main" org.jboss.netty.channel.ChannelException: Failed to bind to: /192.168.3.216:2552

答案 1 :(得分:0)

只是添加有关我之前问题的更多信息:

检测到多个主要类别,选择一个运行:

[1] com.goticks.BackendMain  
[2] com.goticks.BackendRemoteDeployMain  
[3] com.goticks.FrontendMain  
[4] com.goticks.FrontendRemoteDeployMain  
[5] com.goticks.FrontendRemoteDeployWatchMain  
[6] com.goticks.SingleNodeMain  

Enter number: 2  

[info] Running com.goticks.BackendRemoteDeployMain
[DEBUG] [04/18/2016 15:54:11.554] [run-main-0] [EventStream(akka://backend)]     logger log1-Logging$DefaultLogger started  
[DEBUG] [04/18/2016 15:54:11.555] [run-main-0] [EventStream(akka://backend)] Default Loggers started  
[INFO] [04/18/2016 15:54:11.591] [run-main-0] [akka.remote.Remoting] Starting remoting  
[ERROR] [04/18/2016 15:54:11.748] [backend-akka.remote.default-remote-dispatcher-5] [NettyTransport(akka://backend)] failed to bind to /192.168.1.9:2551, shutting down Netty transport  
[ERROR] [04/18/2016 15:54:11.757] [run-main-0] [akka.remote.Remoting] Remoting error: [Startup failed] [
akka.remote.RemoteTransportException: Startup failed at    
akka.remote.Remoting.akka$remote$Remoting$$notifyError(Remoting.scala:136)
        at akka.remote.Remoting.start(Remoting.scala:201)  
        at akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:184)  
        at akka.actor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:663)    
        at akka.actor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:660)  
        at akka.actor.ActorSystemImpl._start(ActorSystem.scala:660)  
        at akka.actor.ActorSystemImpl.start(ActorSystem.scala:676)  
        at akka.actor.ActorSystem$.apply(ActorSystem.scala:143)  
        at akka.actor.ActorSystem$.apply(ActorSystem.scala:120)  
        at com.goticks.BackendRemoteDeployMain$.delayedEndpoint$com$goticks$BackendRemoteDeployMain$1(BackendRemoteDeployMain.scala:9)  
        at com.goticks.BackendRemoteDeployMain$delayedInit$body.apply(BackendRemoteDeployMain.scala:6)  
        at scala.Function0$class.apply$mcV$sp(Function0.scala:34)  
        at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)  
        at scala.App$$anonfun$main$1.apply(App.scala:76)  
        at scala.App$$anonfun$main$1.apply(App.scala:76)  
        at scala.collection.immutable.List.foreach(List.scala:381)  
        at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)  
        at scala.App$class.main(App.scala:76)  
        at   com.goticks.BackendRemoteDeployMain$.main(BackendRemoteDeployMain.scala:6)  
        at com.goticks.BackendRemoteDeployMain.main(BackendRemoteDeployMain.scala)  
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
        at java.lang.reflect.Method.invoke(Unknown Source)  
        at sbt.Run.invokeMain(Run.scala:67)  
        at sbt.Run.run0(Run.scala:61)  
        at sbt.Run.sbt$Run$$execute$1(Run.scala:51)  
        at sbt.Run$$anonfun$run$1.apply$mcV$sp(Run.scala:55)  
        at sbt.Run$$anonfun$run$1.apply(Run.scala:55)  
        at sbt.Run$$anonfun$run$1.apply(Run.scala:55)  
        at sbt.Logger$$anon$4.apply(Logger.scala:85)  
        at sbt.TrapExit$App.run(TrapExit.scala:248)  
        at java.lang.Thread.run(Unknown Source)  
 Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /192.168.1.9:2551  
        at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)  
        at akka.remote.transport.netty.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:410)  
        at akka.remote.transport.netty.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:406)