【问题标题】:Failure to Bind to a Remote IP Address for Akka Actor System无法绑定到 Akka Actor 系统的远程 IP 地址
【发布时间】:2012-09-04 18:56:31
【问题描述】:

我在初始化远程 IP 地址上的参与者系统时遇到了问题。我正在使用 akka 演员和戏剧!框架。代码和远程参与者系统都在远程机架空间服务器上。当我尝试在另一台服务器上创建远程参与者系统时,它无法绑定到该 IP 地址。我认为这不是网络或防火墙问题,因为 Rackspace 说他们打开了服务器之间的所有连接。这是我收到的错误消息:

[error] application - 

! Internal server error, for request [POST /payment/] ->

java.lang.ExceptionInInitializerError: null
    at     Routes$$anonfun$routes$1$$anonfun$apply$3$$anonfun$apply$4.apply(routes_routing.scala:44) ~[classes/:na]
    at Routes$$anonfun$routes$1$$anonfun$apply$3$$anonfun$apply$4.apply(routes_routing.scala:44) ~[classes/:na]
    at play.core.Router$HandlerInvoker$$anon$3.call(Router.scala:1080) ~[play_2.9.1-2.0.1.jar:2.0.1]
    at play.core.Router$Routes$class.invokeHandler(Router.scala:1255) ~[play_2.9.1-2.0.1.jar:2.0.1]
    at Routes$.invokeHandler(routes_routing.scala:14) ~[classes/:na]
    at Routes$$anonfun$routes$1$$anonfun$apply$3.apply(routes_routing.scala:44) ~[classes/:na]

Caused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /172.17.100.232:2554
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298) ~[netty-3.3.0.Final.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-2.0.2.jar:2.0.2]
    at akka.actor.ActorSystemImpl.start(ActorSystem.scala:575) ~[akka-actor-2.0.2.jar:2.0.2]

Caused by: java.net.BindException: Cannot assign requested address
    at sun.nio.ch.Net.bind(Native Method) ~[na:1.6.0_26]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:126) ~[na:1.6.0_26]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59) ~[na:1.6.0_26]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:140) ~[netty-3.3.0.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:92) ~[netty-3.3.0.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66) ~[netty-3.3.0.Final.jar:na]

我在这里创建远程actor系统:

object Payment extends Controller {
  var goodies: AuthNetActorObject = null

  val system = ActorSystem("RemoteCreation", ConfigFactory.load.getConfig("remotecreation"))
  val myActor = system.actorOf(Props[authNetActor.AuthNetActorMain], name = "remoteActor")
  ...
}

这是我在 Application.conf 文件中定义远程创建的地方:

remotecreation{ #user defined name for the configuration
    include "common"
    akka {
            actor{
                    #serializer{
                    #       proto = "akka.serialization.ProtobufSerializer"
                    #       daemon-create = "akka.serialization.DaemonMsgCreateSerializer"
                    #}

                    #serialization-bindings{
                    #       "com.google.protobuf.GeneratedMessage" = proto
                    #       "akka.remote.DaemonMsgCreate" = daemon-create
                    #}

                    deployment{
                            /remoteActor{   #Specifically has to be the name of the remote actor
                                    remote="akka://RemoteCreation@172.17.100.232:2554"
                            #       router = "round-robin"
                            #       nr-of-instances = 10
                            #       target {
                            #               nodes = ["akka://RemoteCreation@172.17.100.232:2554", "akka://RemoteCreation@172.17.100.224:2554"]
                            #       }
                            }
                    }
            }
    }
}

这是我在定义中包含的 common.conf 文件:

akka {

  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }

  remote {
        transport = "akka.remote.netty.NettyRemoteTransport"
        log-received-messages = on
        log-sent-messages = on
        log-remote-lifecycle-events = on

    netty {
      hostname = "172.17.100.232"       #Broadcast IP address of remote system
      port = 2554
        log-received-messages = on
        log-sent-messages = on
          log-remote-lifecycle-events = on

    }
  }
}

【问题讨论】:

    标签: scala network-programming playframework akka remote-actors


    【解决方案1】:

    这可能意味着其他东西正在使用该机器上的该端口。登录该机器并以 root 身份运行 netstat -anp | grep 2554 并查看该端口处于 LISTEN 状态。如果是这样,进程 ID 将位于最后一列。

    【讨论】:

    • 感谢您的回复!我 ssh 进入远程机器,成为超级用户并输入该命令。没有任何东西被退回。当我在没有 grep 的情况下执行此操作时,我无法找到端口 2554。我还尝试了 netstat -l,它列出了所有侦听端口,但无法在那里找到它。此外,似乎有些东西正在使用所有正在侦听的端口。我会尝试切换到其中一个并为您提供更新。感谢您的帮助:)。
    • 是的,它无法绑定。我会尝试找到一个开放的。
    • 好的,我只需要在远程ip和端口上创建一个应用服务。 groups.google.com/forum/?fromgroups=#!topic/akka-user/…
    • @user687245:您找到解决问题的方法了吗?我也面临同样的问题。我已经尝试过 netstat,但它没有返回绑定到配置端口的任何内容。
    • 嗨@VaibhavRaj:你必须在这些服务器上创建一个演员系统。因此,您必须在那里运行代码并检查是否设置了服务并且是该服务器的侦听端口。然后你就可以在该服务器上生成远程 akka 演员了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    • 2017-12-07
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多