Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processor actor terminated abruptly on HTTPs connections (akka 2.4.12, akka-http 2.4.11) #497

Closed
samidalouche opened this issue Nov 8, 2016 · 6 comments

Comments

5 participants
@samidalouche
Copy link

commented Nov 8, 2016

I posted on akka-user, but since I believe it might be a bug, I am opening an issue for that.

The problem seems to be that when performing HTTPS queries using a connection pool, shutting down the actor system raises the following error:

ERROR akka.actor.ActorSystemImpl - Outgoing request stream error
akka.stream.AbruptTerminationException: Processor actor [Actor[akka://default/user/StreamSupervisor-1/flow-0-0-unknown-operation#-901476425]] terminated abruptly

An example of simple code that reproduces the problem (replace the https prefix by http in the uri field to make the problem disappear)

object HttpsWithConnectionPoolIssue extends App {

  implicit val system = ActorSystem()
  implicit val materializer = ActorMaterializer()
  implicit val timeout = Timeout(10.seconds)
  import system.dispatcher

  val request = HttpRequest(
    uri = "https://httpstatuses.com/200"
  )

  val future = Http(system)
    .singleRequest(request)
    .map(_.discardEntityBytes())

  val systemTerminatedFuture = future.flatMap { _ =>
    Http().shutdownAllConnectionPools().flatMap { _ =>
      materializer.shutdown()
      system.terminate()
    }
  }

  Await.result(systemTerminatedFuture, Duration.Inf)
}

An example of code that does not exhibit the problem (no connection pool)

object HTTPsConnectionNotExhibitingProblem extends App {

  implicit val system = ActorSystem()
  implicit val materializer = ActorMaterializer()
  implicit val timeout = Timeout(10.seconds)
  import system.dispatcher

  val request = HttpRequest(
    uri = "/200"
  )

  val flow = Http(system).outgoingConnectionHttps("httpstatuses.com")

  val source = Source.single(request)
    .via(flow)
    .map(_.discardEntityBytes())

  val sourceProcessed = source.runWith(Sink.ignore)

  val systemTerminatedFuture = sourceProcessed.flatMap { _ =>
    Http().shutdownAllConnectionPools().flatMap { _ =>
      materializer.shutdown()
      system.terminate()
    }
  }

  Await.result(systemTerminatedFuture, Duration.Inf)
}
@jrudolph

This comment has been minimized.

Copy link
Member

commented Nov 10, 2016

This error message is probably harmless. The reason it occurs is that when an ActorSystem is shutdown it stops all its actors. The streaming infrastructure relies on those actors and then complains that something has shutdown the actors. This happens in particular with the connection pool actors as these streams need to be kept alive for future requests.

Still, it's unfortunate, that these expected errors are logged verbosely in the console (we are also seeing them in tests). Here's a related ticket from akka to improve the situation: akka/akka#18747

@jrudolph jrudolph added this to the backlog milestone Nov 10, 2016

@jonas

This comment has been minimized.

Copy link
Member

commented Nov 10, 2016

It's also somewhat related with #450.

@arturaz

This comment has been minimized.

Copy link

commented Feb 3, 2017

I have also stumbled upon this. Repro at https://github.com/arturaz/akka-http-https-bug-repro

@BusyByte

This comment has been minimized.

Copy link

commented Feb 5, 2017

We are also seeing this issue. It's harmless as the code executes but really confusing to the users of our CLI which uses akka-http as they think there's been an error when nothing is wrong.

@BusyByte

This comment has been minimized.

Copy link

commented Feb 5, 2017

We are using singleRequest and shutdown like:

Await.result(httpExt.shutdownAllConnectionPools(), shutDownWaitTime)
Await.result(actorSystem.terminate(), shutDownWaitTime)
@jrudolph

This comment has been minimized.

Copy link
Member

commented Feb 27, 2017

I created #907 to track further improvements in the shutdown process.

Closing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.