I'm using Akka Http and Akka streams 2.0.1 to process data from a streaming 
HTTP API. For my usecase I need to make sure I shutdown (and restart) my 
app in the following scenarios:


   1. Client disconnect (connection is closed by something on my end)
   2. I receive a zero byte chunk, which means a force disconnect by the 
   server
   3. I didn't receive any non empty chunks for more than 30 seconds

In my code I'm doing something like this:


class MyClient extends Actor with ActorLogging {

  val client = 
Http(context.system).outgoingConnectionTls("http://somewhere",443)

  override def receive = {
    case "start" => Source.single(HttpRequest(GET)) via client runWith 
Sink.head pipeTo self
    case response: HttpResponse if response.status.isSuccess =>
      response.entity.dataBytes.map(processor ! _).runWith(Sink.onComplete 
{ // processor is an actorRef that handles further processing/parsing
        case _ => 
          log.error("Stream ended unexpectedly")
          context.system.registerOnTermination(sys.exit(1))

  }
}

So when the stream ends, my app is shutting down. For unhandled errors in 
the stream I'm using: 
Supervision.Stop

I have trouble handling scenario 3. I know Akka Http has 
akka.http.client.idle-timeout setting, but this is not really helping. How 
can I make sure I end the stream when it is inactive for more than X 
seconds?

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to