Dear All,

I have some problem with remote akka. 

I'm trying to create one akka remote actor node and connect it from a 
different machine. I opened 
the port 2551,2552,2553 ports of both the machines. But after creating the 
remote actor in one machine I'm 
not able to access it from the other machine. Even I'm not able to access 
the process via TELNET, but in NETSTAT the 
process reviels its running status in port 2551.

Please help me ..I am pasting my code snippet along with this mail... 

My code snipet for machine A(remote):
_____________________________________

1. Conf file:

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
   }
   remote {
     transport = "akka.remote.netty.NettyRemoteTransport"
     netty.tcp {
       hostname = "192.168.161.131"
       port = 2551
     }
   }
}

2. Code:

import akka.actor._
import com.typesafe.config.ConfigFactory
import java.io.File
import com.typesafe.config.ConfigParseOptions

object HelloRemote  {
  def main(args: Array[String]): Unit = {
  val rootCfg = ConfigFactory.parseFile(new File("./test/remote.conf"), 
ConfigParseOptions.defaults())
  val system = ActorSystem("HelloRemoteSystem", rootCfg)
  val remoteActor = system.actorOf(Props[RemoteActor], name = "RemoteActor")
  remoteActor ! "The RemoteActor is alive"
  }
}

class RemoteActor extends Actor {
  def receive = {
    case msg: String =>
        println(s"RemoteActor received message '$msg'")
        sender ! "Hello from the RemoteActor"
  }
}




My code snipet for machine B(Local):

1. Conf file:

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty.tcp {
      hostname = "192.168.161.222"
      port = 2551
    }
  }
}


2. Code:

import akka.actor._
import com.typesafe.config.ConfigFactory
import java.io.File
import com.typesafe.config.ConfigParseOptions

object Local {
  def main(args: Array[String]): Unit = {
  val rootCfg = ConfigFactory.parseFile(new File("./test/local.conf"), 
ConfigParseOptions.defaults())
  implicit val system = ActorSystem("LocalSystem", rootCfg)
  val localActor = system.actorOf(Props[LocalActor], name = "LocalActor") 
 // the local actor
  localActor ! "START"                                                     
// start the action
  }
}

class LocalActor extends Actor {

  // create the remote actor
  val remote = 
context.actorSelection("akka.tcp://[email protected]:2551/user/RemoteActor")
  var counter = 0

  def receive = {
    case "START" =>
        remote.tell("hi")
        remote ! "Hello from the LocalActor"
    case msg: String =>
        println(s"LocalActor received message: '$msg'")
        if (counter < 5) {
            sender ! "Hello back to you"
            counter += 1
        }
  }
}


-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to