Scala Akka远程参与者-:无法在本地和远程参与者之间建立连接

Scala Akka远程参与者-:无法在本地和远程参与者之间建立连接,scala,akka,akka-remote-actor,Scala,Akka,Akka Remote Actor,您好,我遵循这一点,我复制粘贴的代码,因为它是除了我改变了端口从5150到2552,我面临着基地的错误 HelloLocal项目错误 [warn] there were 1 deprecation warning(s); re-run with -deprecation for details [warn] one warning found [info] Running HelloLocal [INFO] [11/04/2014 22:37:50.707] [run-main-0] [Re

您好,我遵循这一点,我复制粘贴的代码,因为它是除了我改变了端口从5150到2552,我面临着基地的错误 HelloLocal项目错误

 [warn] there were 1 deprecation warning(s); re-run with -deprecation for details
[warn] one warning found
[info] Running HelloLocal 
[INFO] [11/04/2014 22:37:50.707] [run-main-0] [Remoting] Starting remoting
[INFO] [11/04/2014 22:37:51.857] [run-main-0] [Remoting] Remoting started; listening on addresses :[akka.tcp://LocalSystem@127.0.1.1:2552]
[INFO] [11/04/2014 22:37:51.863] [run-main-0] [Remoting] Remoting now listens on addresses: [akka.tcp://LocalSystem@127.0.1.1:2552]
[ERROR] [11/04/2014 22:37:51.904] [LocalSystem-akka.actor.default-dispatcher-3] [RemoteActorRefProvider] Error while looking up address [akka://HelloRemoteSystem@127.0.0.1:2552]
akka.remote.RemoteTransportException: No transport is loaded for protocol: [akka], available protocols: [akka.tcp]
    at akka.remote.Remoting$.localAddressForRemote(Remoting.scala:88)
    at akka.remote.Remoting.localAddressForRemote(Remoting.scala:130)
    at akka.remote.RemoteActorRefProvider.actorFor(RemoteActorRefProvider.scala:321)
    at akka.actor.ActorRefFactory$class.actorFor(ActorRefProvider.scala:258)
    at akka.actor.ActorCell.actorFor(ActorCell.scala:369)
    at LocalActor.<init>(HelloLocal.scala:7)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at akka.util.Reflect$.instantiate(Reflect.scala:45)
    at akka.actor.NoArgsReflectConstructor.produce(Props.scala:361)
    at akka.actor.Props.newActor(Props.scala:252)
    at akka.actor.ActorCell.newActor(ActorCell.scala:552)
    at akka.actor.ActorCell.create(ActorCell.scala:578)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
    at akka.dispatch.Mailbox.run(Mailbox.scala:219)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

[INFO] [11/04/2014 22:37:51.913] [LocalSystem-akka.actor.default-dispatcher-5] [akka://HelloRemoteSystem@127.0.0.1:2552/user/RemoteActor] Message [java.lang.String] from Actor[akka://LocalSystem/user/LocalActor#543076206] to Actor[akka://HelloRemoteSystem@127.0.0.1:2552/user/RemoteActor] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
我是阿克卡的新手,出于学习目的,我正在学习本教程,现在有错误,请帮助我解决

在akka汇款2.3.6之后进行编辑,现在我有不同的错误 application.conf(helloLocal)

鳞片海洛洛卡 输入akka.actor_

class LocalActor extends Actor {
  //create the remote actor 
  val remote = context.actorSelection("akka.tcp://HelloRemoteSystem@127.0.0.1:2552/user/RemoteActor")

  var counter = 0
def receive = {
    case "START" =>
        remote ! "Hello from the LocalActor"
    case msg: String =>
        println(s"LocalActor received message: '$msg'")
        if (counter < 5) {
            sender ! "Hello back to you"
            counter += 1
        }
  }
}
object HelloLocal extends App{
  implicit val system =ActorSystem("LocalSystem")
  val localActor =system.actorOf(Props[LocalActor],name="LocalActor")
  localActor ! "START"

}
这些就是现在的错误 HelloLocal

[info] Running HelloLocal 
[INFO] [11/05/2014 12:42:32.674] [run-main-1] [Remoting] Starting remoting
[INFO] [11/05/2014 12:42:34.031] [run-main-1] [Remoting] Remoting started; listening on addresses :[akka.tcp://LocalSystem@127.0.0.1:45047]
[INFO] [11/05/2014 12:42:34.040] [run-main-1] [Remoting] Remoting now listens on addresses: [akka.tcp://LocalSystem@127.0.0.1:45047]
[WARN] [11/05/2014 12:42:34.367] [LocalSystem-akka.remote.default-remote-dispatcher-5] [akka.tcp://LocalSystem@127.0.0.1:45047/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FHelloRemoteSystem%40127.0.0.1%3A2552-0/endpointWriter] AssociationError [akka.tcp://LocalSystem@127.0.0.1:45047] -> [akka.tcp://HelloRemoteSystem@127.0.0.1:2552]: Error [Invalid address: akka.tcp://HelloRemoteSystem@127.0.0.1:2552] [
akka.remote.InvalidAssociation: Invalid address: akka.tcp://HelloRemoteSystem@127.0.0.1:2552
Caused by: akka.remote.transport.Transport$InvalidAssociationException: Connection refused: /127.0.0.1:2552
]
[WARN] [11/05/2014 12:42:34.419] [LocalSystem-akka.remote.default-remote-dispatcher-13] [Remoting] Tried to associate with unreachable remote address [akka.tcp://HelloRemoteSystem@127.0.0.1:2552]. Address is now gated for 5000 ms, all messages to this address will be delivered to dead letters. Reason: Connection refused: /127.0.0.1:2552
[INFO] [11/05/2014 12:42:34.451] [LocalSystem-akka.actor.default-dispatcher-2] [akka://LocalSystem/deadLetters] Message [java.lang.String] from Actor[akka://LocalSystem/user/LocalActor#1798933307] to Actor[akka://LocalSystem/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
他的远程错误是

[info] Running HelloRemote 
Remote Actor receive messgage : The remote actor is alive  
[INFO] [11/05/2014 12:42:35.654] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#1925624739] to Actor[akka://HelloRemoteSystem/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

您可能使用的akka版本比教程中使用的版本更新

对于2.2.3及以上版本,您的配置需要类似于

akka {
 actor {
  provider = "akka.remote.RemoteActorRefProvider"
 }
remote {
  enabled-transports = ["akka.remote.netty.tcp"]
  netty.tcp {
   hostname = "127.0.0.1"
   port = 2552
  }
 }
}

根据您的版本,您可以在以下位置找到更多信息:

您可能正在使用比本教程中使用的更为最新的akka版本

对于2.2.3及以上版本,您的配置需要类似于

akka {
 actor {
  provider = "akka.remote.RemoteActorRefProvider"
 }
remote {
  enabled-transports = ["akka.remote.netty.tcp"]
  netty.tcp {
   hostname = "127.0.0.1"
   port = 2552
  }
 }
}

根据您的版本,您可以在以下位置找到更多信息:

我假设您首先启动了远程参与者,然后尝试发送您的消息?我首先启动本地参与者,然后启动远程参与者,因为在本教程的最后提到了它“当本地参与者系统启动时,它将向远程参与者系统发送初始消息。远程参与者将发送回复“因此,我先启动本地actor,然后启动远程actor。您需要先启动远程actor。当你首先启动本地系统时,它会向一个不存在的远程系统发送一条消息。非常感谢:)它现在可以工作了。你能给我推荐一些关于akka远程处理的阅读材料吗..akka文档对远程处理非常抽象。我假设你先启动了远程参与者,然后尝试发送消息?我正在启动本地参与者首先是远程参与者,因为在教程的末尾提到“当本地参与者系统启动时,它将向远程参与者系统发送一条初始消息。远程参与者将发送一条回复”因此,我首先启动本地参与者,然后是远程参与者。您需要首先启动远程参与者。当你首先启动本地系统时,它会向一个不存在的远程系统发送一条消息。非常感谢:)它现在可以工作了。你能给我推荐一些关于akka远程处理的阅读材料吗
[info] Running HelloRemote 
Remote Actor receive messgage : The remote actor is alive  
[INFO] [11/05/2014 12:42:35.654] [HelloRemoteSystem-akka.actor.default-dispatcher-2] [akka://HelloRemoteSystem/deadLetters] Message [java.lang.String] from Actor[akka://HelloRemoteSystem/user/RemoteActor#1925624739] to Actor[akka://HelloRemoteSystem/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
akka {
 actor {
  provider = "akka.remote.RemoteActorRefProvider"
 }
remote {
  enabled-transports = ["akka.remote.netty.tcp"]
  netty.tcp {
   hostname = "127.0.0.1"
   port = 2552
  }
 }
}