I assume you mean as described 
in 
http://doc.akka.io/docs/akka-http/10.0.5/scala/http/low-level-server-side-api.html#connection-failures
 
and 
http://doc.akka.io/docs/akka-http/10.0.5/scala/http/low-level-server-side-api.html#connections-source-failures
 
?

Neither of those actually report an error when the client forcibly closes 
the connection

On Thursday, May 4, 2017 at 3:12:24 AM UTC-5, johannes...@lightbend.com 
wrote:
>
> Hi Richard,
>
> the behavior you describe is as expected. The ask ActorRef has no relation 
> to the connection and so watching it doesn't have the desired effect.
>
> The routing DSL doesn't even know about the concept of connections. It 
> only handles single requests and doesn't get notified in any way when the 
> connection is closed. I think being able to watch the underlying connection 
> close might be a useful feature. Could you create a ticket for it on github?
>
> The best bet for observing termination of the underlying connection right 
> now is going down a level to the `Http.bindAndHandle` API and add a 
> component to your flow that watches for termination of the per-connection 
> handler flow. An alternative could be to watch the entity stream of the 
> request or the response which will be notified through a stream error (on 
> the request side) or cancellation (on the response side) when the 
> connection is closed.
>
> HTH
> Johannes
>
> On Wednesday, May 3, 2017 at 5:12:15 PM UTC+2, richard wrote:
>>
>>
>> The following experiment registers for termination of the internal actor 
>> used by the ask pattern. 
>>
>> The Termination message is received when the route completes normally or 
>> times out. Closing the connection from the client has no impact on the 
>> internal actor, which survives until the timeout finally expires. 
>>
>> This is sufficient to avoid a leak of the resources used by the internal 
>> actor.
>>
>> However, it means that the actor (Tracker) that is actually responding to 
>> the HTML request is unaware that the response cannot be delivered. That is 
>> unfortunate for use cases with expensive response processing and lengthy 
>> timeouts to cover the worst case.
>>
>>
>> import java.util.concurrent.TimeUnit
>>
>> import akka.actor.{Actor, Props, Terminated}
>> import akka.http.scaladsl.server.Directives._
>> import akka.http.scaladsl.server.Route
>> import akka.util.Timeout
>>
>> object DeathWatcher extends App {
>>
>>   import akka.actor.ActorSystem
>>   import akka.http.scaladsl.Http
>>   import akka.http.scaladsl.model._
>>   import akka.stream.ActorMaterializer
>>
>>   implicit val system = ActorSystem()
>>   implicit val materializer = ActorMaterializer()
>>   implicit val executionContext = system.dispatcher
>>
>>   class Tracker extends Actor {
>>     override def receive: Receive = {
>>       case Terminated(c) =>
>>         println("terminated", c)
>>       case _: String =>
>>         context.watch(sender)
>>     }
>>   }
>>
>>   val tracker = system.actorOf(Props[Tracker])
>>
>>   import akka.pattern.ask
>>
>>   implicit val timeout = Timeout(5, TimeUnit.SECONDS)
>>
>>   val route: Route =
>>     path("success") {
>>       onComplete(tracker ? "xxx") { r =>
>>         complete(StatusCodes.OK)
>>       }
>>     }
>>
>>   Http().bindAndHandle(route, "localhost", 8080)
>> }
>>
>>
>>
>>
>>
>>
>>
>>
>>

-- 
>>>>>>>>>>      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