Seems like I'm having the same issue.
object TestClient {
implicit val system = ActorSystem()
implicit val fm = FlowMaterializer()
val connection = Http().outgoingConnection("localhost", 8080)
def request() = {
val result = Source.singleton(HttpRequest(GET, Uri("/ping"))).via(connection.flow).runWith(Sink.head)
Await.result(result, 10.seconds)
}
}
object TestServer {
implicit val system = ActorSystem()
implicit val fm = FlowMaterializer()
def bind() {
val binding = Http().bind(interface = "localhost", port = 8080)
binding startHandlingWithSyncHandler {
case HttpRequest(GET, Uri.Path("/ping"), _, _, _) => HttpResponse(entity = "PONG!")
case _: HttpRequest => HttpResponse(404, entity = "Unknown resource!")
}
}
}
Server.bind
In another repl (first request works. subsequent requests fail)
scala> TestClient.request
res0: akka.http.model.HttpResponse = HttpResponse(200 OK,List(Date: Wed, 10 Dec 2014 20:22:04 GMT, Server: akka-http/2.3.7),HttpEntity.Default(text/plain; charset=UTF-8,5,SourcePipe(PublisherSource(akka.stream.impl.MultiStreamOutputProcessor$SubstreamOutput@5656b4fa),List(Collect(<function1>,OperationAttributes(List(Name(collect))))),List(),OperationAttributes(List()))),HttpProtocol(HTTP/1.1))
scala> TestClient.request
java.util.NoSuchElementException: empty stream
at akka.stream.scaladsl.HeadSink$HeadSinkSubscriber.onComplete(ActorFlowSink.scala:108)
at akka.stream.impl.fusing.ActorOutputBoundary.complete(ActorInterpreter.scala:167)
at akka.stream.impl.fusing.ActorOutputBoundary.onUpstreamFinish(ActorInterpreter.scala:194)
But I can 'curl localhost:8080/ping' all day long without problems.