Search code examples
scalaplayframeworkakkaplayframework-2.2

remote akka actors not working on play frameworks


this is my first post on stackoverflow, and english is not my native language, so apologize if there are mistakes in the post.

I am trying to run remote actors with play framework, but I can't make them work properly. it is a simple client-server system, and both systems are in separate proyects.

client controller index function is something like:

val system = ActorSystem("MySystem")
val servidorRyP = system.actorSelection("akka.tcp://[email protected]:5000/user/servidorRyP")
servidorRyP ! id.toString

and akka configuration in conf file for the client:

#akka
akka.default-dispatcher.core-pool-size-max = 64
akka.debug.receive = on

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

}

if I uncomment the provider file, it show and error: "NoSuchMethodException: akka.remote.RemoteActorRefProvider.", so I left ir commented.

By other side, server controller declares the actor and starts it:

val system = ActorSystem("Servidor")
val servidor = system.actorOf(Props[ServidorRyP], name = "servidorRyP")

I am able to send messages to the actor from the Server application, but I can't reach it from the client.

the akka configuration on Server conf file is:

akka {
actor {
//provider = "akka.remote.RemoteActorRefProvider"
deployment {
/servidorRyP {
remote = "akka.tcp://[email protected]:5000"
}
}
}
}

When I execute both applications (in diferent ports) with play, launching the server before the client, It does nothing, I mean that the client seems to execute the code, but the server does not receive anything.

I am using Play for Mac, but as far as i know, there are no firewall problems.


Solution

  • Did you add akka-remote to your dependencies? It's not included by default.

    Add:

    "com.typesafe.akka" %% "akka-remote" % "2.2.3"
    

    to your build file.