i'm experimenting with scala parallel collections. I'm trying to get data from a local server, that I've set up, this is my code
val httpRequestInputs = List(inputs).par
def getResponse(data: String, url: String) = {
val request = basicRequest.body(text).post(url)
.headers(Map("content-type" -> "text/plain", "charset" -> "utf-8"))
.response(asString)
implicit val backend
= HttpURLConnectionBackend(options = SttpBackendOptions.connectionTimeout(5.minutes))
request.readTimeout(5.minutes).send().body
}
// program executes from here
httpRequestInputs.foreach { input =>
val result = getResponse(input, url)
result match {
case Right(value) => println(value)
case Left(value) => println("error")
}
when using inputs of small size, there is no problem, but, when I try with large input size,
the program throws SocketException
, and I checked the server, the server has no errors,
it seems to me, that the client is closing the connection early. And, these large inputs,
usually take less than 90 seconds to get response, when run individually.
I tried to extend the connection and read timeout options in the http request, but still I'm getting the exception.
can anyone help me understand, why the client is closing the connection?
for http request, i'm using the client com.softwaremill.sttp.client