简体   繁体   中英

Akka Remoting: Connection refused: no further information in “tell” method

I have the same problem you had sometime ago: " Getting errors with remote actor deployment in Akka 2.0 RC2 "

How did yousolve it? I'm using Akka 2.1.2, but I think my problem is the concept.

I create the actor:

ActorRef actorOf = system.actorOf(new Props(HelloWorld.class), "injbct");

and then in other jvm I try to lookup it up :

ActorRef actorFor = system.actorFor("akka://KSystem@127.0.0.1:2552/user/injbct");

Regards, José

I have discovered that if you are accessing a remote actor in the same machine the localhost address of 127.0.0.1 or the machine's actual IP address must be used in both the configuration of the remote actor and the actor declaration in the actor user, ie they cannot be mixed.

The remote actor config

remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 2554

Considering the machine to have an IP address of 1.2.3.4, then

This works

val workerRouter = 
    context.actorFor("akka://PrimeWorkerKernel@127.0.0.1:2554/user/PrimeWorkerActor")

This does not and results in a connection refused

val workerRouter = 
    context.actorFor("akka://PrimeWorkerKernel@1.2.3.4:2554/user/PrimeWorkerActor")

For starters, you should read the Akka Remoting documentation . Then, make sure you have the remoting dependency in your pom file:

<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-remote_2.10</artifactId>
  <version>2.1.4</version>
</dependency>

Then, both sides (the calling side and the receiving side will need to have remoting config in their application.conf files similar to the example in the remoting docs:

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

You'll notice that the actor ref provider has been set to the RemoteActorRefProvider as opposed to the default LocalActorRefProvider . Without this on the sending actor side, things won't work. You'll also see that netty binding info has been setup and this is really important on the receiving actor side so that ActorSystem is listening for remote connections and messages. If you follow the steps in the docs and start up your receiving actor system as ActorSystem("KSystem") then things should work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM