Hi Troy, I can't be sure just from what you wrote, but you may be experiencing this issue: https://github.com/spray/spray/issues/883 The issue documented there seems to be a race condition of sorts between your per-connection actor stopping, and spray's per-connection actor stopping.
To answer your question, `context.stop(self)` is a perfectly valid way of stopping an actor. The logged error means another actor (in this case, akka://c0smo/user/IO-UHTTP/listener-0/0, which is an actor created by spray) was watching your actor using DeathWatch. However, when the spray actor received a `Terminated` message saying your actor died, it didn't handle that the message and so died with a DeathPactException. Again, it's possible I'm misunderstanding your case if it's not in fact similar to the ones discussed at that ticket, but it looks the same as them to me. HTH, Daniel Armak On Mon, Jun 23, 2014 at 12:08 AM, Troy Payne <[email protected]> wrote: > Hello, > > I'm using spray for handling Http connections/closes/responses, etc and I > have this in my receive of my akka > > Here i'm spawning a new actor each connection: > > def receive = { > case Http.Connected(_, _) => { > sender ! > Http.Register(context.actorOf(Props(classOf[ApiServiceWorker]))) > } > } > > And then I want to get rid of the actor by stopping it once the connection > is closed > > def close: Receive = { > case _: Http.ConnectionClosed => { > context.stop(self) > } > } > > However, I receive the following. What's the proper way to stop and > terminate an actor? > > c0smo [ERROR] [06/22/2014 21:01:56.171] > [c0smo-akka.actor.default-dispatcher-5] > [akka://c0smo/user/IO-UHTTP/listener-0/0] Monitored actor > [Actor[akka://c0smo/user/api/$a#1564612786]] terminated > (akka.actor.DeathPactException) > > > -- > >>>>>>>>>> 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. > -- >>>>>>>>>> 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.
