{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/17521","labels_url":"https://api.github.com/repos/akka/akka/issues/17521/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/17521/comments","events_url":"https://api.github.com/repos/akka/akka/issues/17521/events","html_url":"https://github.com/akka/akka/issues/17521","id":78081659,"number":17521,"title":"IllegalStateException in HTTP 1.0-RC2 client with pipelining enabled","user":{"login":"egisj","id":3495208,"avatar_url":"https://avatars.githubusercontent.com/u/3495208?v=3","gravatar_id":"","url":"https://api.github.com/users/egisj","html_url":"https://github.com/egisj","followers_url":"https://api.github.com/users/egisj/followers","following_url":"https://api.github.com/users/egisj/following{/other_user}","gists_url":"https://api.github.com/users/egisj/gists{/gist_id}","starred_url":"https://api.github.com/users/egisj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egisj/subscriptions","organizations_url":"https://api.github.com/users/egisj/orgs","repos_url":"https://api.github.com/users/egisj/repos","events_url":"https://api.github.com/users/egisj/events{/privacy}","received_events_url":"https://api.github.com/users/egisj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akka/akka/labels/1%20-%20triaged","name":"1 - triaged","color":"5319e7"},{"url":"https://api.github.com/repos/akka/akka/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/akka/akka/labels/t:http","name":"t:http","color":"ededed"},{"url":"https://api.github.com/repos/akka/akka/labels/t:http:client","name":"t:http:client","color":"ededed"},{"url":"https://api.github.com/repos/akka/akka/labels/t:http:next","name":"t:http:next","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/akka/akka/milestones/50","html_url":"https://github.com/akka/akka/milestones/http-1.0-RC4","labels_url":"https://api.github.com/repos/akka/akka/milestones/50/labels","id":1123079,"number":50,"title":"http-1.0-RC4","description":"","creator":{"login":"drewhk","id":932285,"avatar_url":"https://avatars.githubusercontent.com/u/932285?v=3","gravatar_id":"","url":"https://api.github.com/users/drewhk","html_url":"https://github.com/drewhk","followers_url":"https://api.github.com/users/drewhk/followers","following_url":"https://api.github.com/users/drewhk/following{/other_user}","gists_url":"https://api.github.com/users/drewhk/gists{/gist_id}","starred_url":"https://api.github.com/users/drewhk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewhk/subscriptions","organizations_url":"https://api.github.com/users/drewhk/orgs","repos_url":"https://api.github.com/users/drewhk/repos","events_url":"https://api.github.com/users/drewhk/events{/privacy}","received_events_url":"https://api.github.com/users/drewhk/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":12,"state":"open","created_at":"2015-05-21T11:31:42Z","updated_at":"2015-06-15T15:41:01Z","due_on":"2015-05-28T22:00:00Z","closed_at":null},"comments":2,"created_at":"2015-05-19T13:14:18Z","updated_at":"2015-06-16T14:46:07Z","closed_at":null,"body":"Given this server implementation:\r\n```scala\r\nobject TestServer extends App with Directives {\r\n  implicit val system = ActorSystem()\r\n  implicit val flowMaterializer = ActorFlowMaterializer()\r\n\r\n  val requestHandler: HttpRequest => HttpResponse = {\r\n    _ => HttpResponse()\r\n  }\r\n\r\n  val serverSource = Http().bind(\"localhost\", 8080)\r\n\r\n  serverSource.to(Sink.foreach { connection =>\r\n    connection handleWithSyncHandler requestHandler\r\n  }).run()\r\n}\r\n```\r\n\r\nAnd this client:\r\n```scala\r\nobject BugDemo extends App {\r\n  implicit val actorSystem = ActorSystem()\r\n  implicit val flowMaterializer = ActorFlowMaterializer()\r\n\r\n  val http = Http()\r\n  val req = HttpRequest(HttpMethods.GET, \"http://localhost:8080\")\r\n\r\n  (1 to 100000).foreach { _ => http.singleRequest(req) }\r\n}\r\n```\r\nI often get the following exception:\r\n```\r\n[ERROR] [05/19/2015 13:03:59.045] [default-akka.actor.default-dispatcher-15] [akka://default/user/$a/flow-5-0-actorPublisherSource-actorPublisherSource] onNext is not allowed when the stream has not requested elements, totalDemand was 0\r\njava.lang.IllegalStateException: onNext is not allowed when the stream has not requested elements, totalDemand was 0\r\n\tat akka.stream.actor.ActorPublisher$class.onNext(ActorPublisher.scala:190)\r\n\tat akka.http.impl.engine.client.PoolSlot$FlowInportActor.onNext(PoolSlot.scala:193)\r\n\tat akka.http.impl.engine.client.PoolSlot$FlowInportActor$$anonfun$receive$1.applyOrElse(PoolSlot.scala:197)\r\n\tat akka.actor.Actor$class.aroundReceive(Actor.scala:467)\r\n\tat akka.http.impl.engine.client.PoolSlot$FlowInportActor.akka$stream$actor$ActorPublisher$$super$aroundReceive(PoolSlot.scala:193)\r\n\tat akka.stream.actor.ActorPublisher$class.aroundReceive(ActorPublisher.scala:317)\r\n\tat akka.http.impl.engine.client.PoolSlot$FlowInportActor.aroundReceive(PoolSlot.scala:193)\r\n\tat akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)\r\n\tat akka.actor.ActorCell.invoke(ActorCell.scala:487)\r\n\tat akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)\r\n\tat akka.dispatch.Mailbox.run(Mailbox.scala:221)\r\n\tat akka.dispatch.Mailbox.exec(Mailbox.scala:231)\r\n\tat scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)\r\n\tat scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)\r\n\tat scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)\r\n\tat scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)\r\n```\r\n\r\nLooks like it happens only if pipelining is enabled. I cannot reproduce it all the time, but setting the pipelining limit to fairly high value seems to trigger this behaviour. For example, with the following settings, I get the exception every time I run the above client:\r\n```\r\nakka.http.host-connection-pool {\r\n  max-connections = 10\r\n  pipelining-limit = 15\r\n  max-open-requests = 16384\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/112455771","html_url":"https://github.com/akka/akka/issues/17521#issuecomment-112455771","issue_url":"https://api.github.com/repos/akka/akka/issues/17521","id":112455771,"user":{"login":"sirthias","id":135347,"avatar_url":"https://avatars.githubusercontent.com/u/135347?v=3","gravatar_id":"","url":"https://api.github.com/users/sirthias","html_url":"https://github.com/sirthias","followers_url":"https://api.github.com/users/sirthias/followers","following_url":"https://api.github.com/users/sirthias/following{/other_user}","gists_url":"https://api.github.com/users/sirthias/gists{/gist_id}","starred_url":"https://api.github.com/users/sirthias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirthias/subscriptions","organizations_url":"https://api.github.com/users/sirthias/orgs","repos_url":"https://api.github.com/users/sirthias/repos","events_url":"https://api.github.com/users/sirthias/events{/privacy}","received_events_url":"https://api.github.com/users/sirthias/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T14:46:07Z","updated_at":"2015-06-16T14:46:07Z","body":"I just added a test trying to reproduce the problem:\r\nhttps://github.com/spray/akka/commit/37b9bb5a9be6ac761b7827d2fdb9282f00ff5383\r\n\r\nUnfortunately the test is green, no matter how large I set `N`.\r\nEven with 100,000 requests everything still runs smoothly.\r\n\r\n@egisj Could you try upgrading to RC3 and see whether the problem is still present for you?"}}