In my project i am using streaming method and getting response as Source[ByteStrring, _] from my API via WsClient over http.Then I send this response to client as Result.When I get the result of linux command ls of, i see a lot of TCP socket connections.Their counts always increase and finally system shot down.I developed my code according to play framework's official site.My play framework version is 2.5.10.Here is the code example in play's site that causes this problem
def downloadFile = Action.async {
// Make the request
ws.url(url).withMethod("GET").stream().map {
case StreamedResponse(response, body) =>
// Check that the response was successful
if (response.status == 200) {
// Get the content type
val contentType = response.headers.get("Content-Type").flatMap(_.headOption)
.getOrElse("application/octet-stream")
// If there's a content length, send that, otherwise return the body chunked
response.headers.get("Content-Length") match {
case Some(Seq(length)) =>
Ok.sendEntity(HttpEntity.Streamed(body, Some(length.toLong), Some(contentType)))
case _ =>
Ok.chunked(body).as(contentType)
}
} else {
BadGateway
}
}
}
I didn't modify this code.i used as exactly like this.I would like your help.Thanks.