title: Akka remoting in Java : no result from remote
body: <p>I am running sample example for akka remoting (2.0.2) in java (1.6) and not getting results from remote. It seems that my local node is not able to connect to remote note.</p>
  
  <p>LocalNodeApplication code is on local system and RemoteNodeApplication code is on remote system.</p>
  
  <p>Please refer code :</p>
  
  <p>Local Node -</p>
  
  <pre><code>public class LocalNodeApplication extends Controller {
  
  public static Result process(String msg) throws Exception {
  
      ActorSystem _system = ActorSystem.create("LocalNodeApp", ConfigFactory.load().getConfig("LocalSys"));
      ActorRef localActor = _system.actorOf(new Props(LocalActor.class));
  
      localActor.tell("Hello");
  
      Thread.sleep(5000);
      _system.shutdown();
  
      return ok("success");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>LocalActor code :</p>
  
  <pre><code>public class LocalActor extends UntypedActor {
  LoggingAdapter log = Logging.getLogger(getContext().system(), this);
  Timeout timeout = new Timeout(Duration.parse("5 seconds"));
  
  ActorRef remoteActor;
  
  @Override
  public void preStart() {
      //Get a reference to the remote actor
  
      remoteActor = getContext().actorFor("akka://RemoteNodeApp@192.168.0.85:9002/user/remoteActor");
  }
  
  @Override
  public void onReceive(Object message) throws Exception {
      Future&lt;Object&gt; future = Patterns.ask(remoteActor, message.toString(), timeout);
  
      String result = (String) Await.result(future, timeout.duration());
  
      log.info("Message received from Server -&gt; {}", result);
  
      /*remoteActor.tell(message.toString());*/
  }
  </code></pre>
  
  <p>}</p>
  
  <p>LocalSys config :</p>
  
  <pre><code>LocalSys {
  akka {
      actor {
          provider = "akka.remote.RemoteActorRefProvider"
          deployment {
              /remoteActor {
                  remote = "akka://RemoteNodeApp@192.168.0.85:9002"
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p>Remote Node code -</p>
  
  <p>RemoteNodeApplication</p>
  
  <pre><code>public class RemoteNodeApplication implements Bootable {
  
  final ActorSystem system = ActorSystem.create("RemoteNodeApp", ConfigFactory.load().getConfig("RemoteSys"));
  
  public void shutdown() {
      system.shutdown();
  }
  
  public void startup() {     
      system.actorOf(new Props(RemoteActor.class), "remoteActor");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>RemoteActor :</p>
  
  <pre><code>public class RemoteActor extends UntypedActor {
  @Override
  public void onReceive(Object message) throws Exception {
      if (message instanceof String) {
          // Get reference to the message sender and reply back
          getSender().tell(message + " got something");
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>RemoteSys config -</p>
  
  <pre><code>RemoteSys {
  akka {
      actor {
          provider = "akka.remote.RemoteActorRefProvider"
      }
      remote {
          untrusted-mode = on
          transport = "akka.remote.netty.NettyRemoteTransport"
          netty {
              hostname = "192.168.0.85"
              port = 9002
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <hr>
  
  <p>I am starting play "run 9000" on local node and on remote starting play "run 9002" .</p>
  
  <p>I am getting below mentioned exception :</p>
  
  <pre><code>[INFO] [09/17/2012 17:42:52.206] [play-akka.actor.actions-dispatcher-1] [ActorSystem(LocalNodeApp)] REMOTE: RemoteServerStarted@akka://LocalNodeApp@127.0.0.1:2552
  [INFO] [09/17/2012 17:42:52.406] [LocalNodeApp-akka.actor.default-dispatcher-4] [ActorSystem(LocalNodeApp)] REMOTE: RemoteClientStarted@akka://RemoteNodeApp@192.168.0.85:9002
  [INFO] [09/17/2012 17:42:52.438] [LocalNodeApp-akka.actor.default-dispatcher-1] [ActorSystem(LocalNodeApp)] REMOTE: RemoteClientShutdown@akka://RemoteNodeApp@192.168.0.85:9002
  [ERROR] [09/17/2012 17:42:57.281] [LocalNodeApp-akka.actor.default-dispatcher-4] [akka://LocalNodeApp/user/$a] Timed out
      akka.pattern.AskTimeoutException: Timed out
          at akka.dispatch.DefaultPromise.result(Future.scala:875)
          at akka.dispatch.Await$.result(Future.scala:74)
          at akka.dispatch.Await.result(Future.scala)
          at com.localNodeApp.LocalActor.onReceive(LocalActor.java:30)
          at akka.actor.UntypedActor$$anonfun$receive$1.apply(UntypedActor.scala:154)
          at akka.actor.UntypedActor$$anonfun$receive$1.apply(UntypedActor.scala:153)
          at akka.actor.Actor$class.apply(Actor.scala:318)
          at akka.actor.UntypedActor.apply(UntypedActor.scala:93)
          at akka.actor.ActorCell.invoke(ActorCell.scala:626)
          at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197)
          at akka.dispatch.Mailbox.run(Mailbox.scala:179)
          at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516)
          at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
          at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
          at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
          at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
  Caused by: akka.pattern.AskTimeoutException: Timed out
          at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:274)
          at akka.actor.DefaultScheduler$$anon$6$$anon$7.run(Scheduler.scala:183)
          at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94)
          at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381)
          ... 4 more
   [INFO] [09/17/2012 17:42:57.318] [LocalNodeApp-akka.actor.default-dispatcher-4] [ActorSystem(LocalNodeApp)] REMOTE: RemoteServerShutdown@akka://LocalNodeApp@127.0.0.1:2552
  </code></pre>
  
  <hr>
  
  <p>When I am running the same example on local system for both local node and remote node (for this changed IP address to local system) getting below mentioned lines on console :</p>
  
  <pre><code>[INFO] [09/17/2012 17:42:52.206] [play-akka.actor.actions-dispatcher-1] [ActorSystem(LocalNodeApp)] REMOTE: RemoteServerStarted@akka://LocalNodeApp@127.0.0.1:2552
  [INFO] [09/17/2012 17:42:52.406] [LocalNodeApp-akka.actor.default-dispatcher-4] [ActorSystem(LocalNodeApp)] REMOTE: RemoteClientStarted@akka://RemoteNodeApp@192.168.0.85:9002
  [INFO] [09/17/2012 17:42:52.438] [LocalNodeApp-akka.actor.default-dispatcher-1] [ActorSystem(LocalNodeApp)] REMOTE: RemoteClientShutdown@akka://RemoteNodeApp@192.168.0.85:9002
  [INFO] [09/17/2012 17:42:57.318] [LocalNodeApp-akka.actor.default-dispatcher-4] [ActorSystem(LocalNodeApp)] REMOTE: RemoteServerShutdown@akka://LocalNodeApp@127.0.0.1:2552
  </code></pre>
  
  <p>Please guide me on this.
  Am I following right steps for akka remoting ?</p>