Skip to content

Instantly share code, notes, and snippets.

@kevwil
Last active December 18, 2015 15:48
Show Gist options
  • Save kevwil/5806472 to your computer and use it in GitHub Desktop.
Save kevwil/5806472 to your computer and use it in GitHub Desktop.
AskTimeoutException
package my.test.app
import akka.actor.{ActorSystem,Props}
import akka.io.IO
import spray.can.Http
object Boot extends App {
implicit val system = ActorSystem("Tester")
val service = system.actorOf(Props[TesterActor], "tester-service")
IO(Http) ! Http.Bind(service, interface = "0.0.0.0", port = 8080)
}
[ERROR] [06/18/2013 09:40:49.625] [Presence-akka.actor.default-dispatcher-5] [akka://Presence/user/presence-service] Error during processing of
request HttpRequest(GET,http://localhost:8080/stats,List(Host: localhost:8080, User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.
0 OpenSSL/0.9.8x zlib/1.2.5),EmptyEntity,HTTP/1.1)
akka.pattern.AskTimeoutException: Recipient[Actor[akka://Presence/user/HTTP/listener-0]] had already been terminated.
at akka.pattern.AskSupport$class.ask(AskSupport.scala:79)
at akka.pattern.package$.ask(package.scala:41)
at akka.pattern.AskSupport$AskableActorRef.ask(AskSupport.scala:124)
at com.ecollege.presence.PresenceService$$anonfun$2.apply(PresenceService.scala:77)
at com.ecollege.presence.PresenceService$$anonfun$2.apply(PresenceService.scala:78)
at spray.routing.directives.RouteDirectives$$anonfun$complete$1$$anon$7.apply(RouteDirectives.scala:52)
at spray.routing.directives.RouteDirectives$$anonfun$complete$1$$anon$7.apply(RouteDirectives.scala:51)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.BasicDirectives$$anonfun$mapRequestContext$1$$anonfun$apply$1.apply(BasicDirectives.scala:30)
at spray.routing.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$2.apply(ExecutionDirectives.scala:34)
at spray.routing.directives.ExecutionDirectives$$anonfun$handleExceptions$1$$anonfun$apply$2.apply(ExecutionDirectives.scala:32)
at spray.routing.HttpServiceBase$class.runSealedRoute$1(HttpService.scala:36)
at spray.routing.HttpServiceBase$$anonfun$runRoute$1.applyOrElse(HttpService.scala:46)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
at akka.actor.ActorCell.invoke(ActorCell.scala:386)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
at akka.dispatch.Mailbox.run(Mailbox.scala:212)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
package my.test.app
import akka.actor.Actor
import spray.routing._
import spray.http._
import MediaTypes._
class TesterActor extends HttpServiceActor with TesterService {
// def actorRefFactory = context
def receive = runRoute(myRoute)
}
package my.test.app
// this should not be necessary, but ...
import reflect.ClassTag
import spray.httpx.marshalling.Marshaller
import scala.concurrent.Future
import scala.concurrent.duration._
import spray.can.server.Stats
import spray.can.Http
import akka.pattern.ask
import spray.util._
import spray.routing._
import spray.http._
import MediaTypes._
trait TesterService extends HttpService {
// copying some stuff from online sample code
implicit def executionContext = actorRefFactory.dispatcher
implicit val statsMarshaller: Marshaller[Stats] =
Marshaller.delegate[Stats, String](ContentTypes.`text/plain`) { stats =>
"Uptime : " + stats.uptime.formatHMS + '\n' +
"Total requests : " + stats.totalRequests + '\n' +
"Open requests : " + stats.openRequests + '\n' +
"Max open requests : " + stats.maxOpenRequests + '\n' +
"Total connections : " + stats.totalConnections + '\n' +
"Open connections : " + stats.openConnections + '\n' +
"Max open connections : " + stats.maxOpenConnections + '\n' +
"Requests timed out : " + stats.requestTimeouts + '\n'
}
val myRoute = {
path("stats") {
get {
complete {
actorRefFactory.actorFor("/user/HTTP/listener-0")
.ask(Http.GetStats)(1.second)
.mapTo[Stats]
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment