I have written an API that takes couple of minutes to create a response. This apparently results in connection resets:
curl: (56) Recv failure: Connection reset by peer
I have tried following timeout configurations from Akka HTTP but nothing seems to solve the above issue.
akka.http.server.idle-timeout = 600 s
akka.http.client.idle-timeout = 600 s
akka.http.server.request-timeout = 600 s
I suspect the issue is with the idle-timeout. But the above configuration doesn't seem to take any affect.
Could anyone please suggest what could be the issue?
I have tried a reverse scenario where i have set the idle-timeout to 5s which is suppose to reset the connection but even that doesn't work. Not sure what is really wrong here. Could anyone please explain this behaviour and how can I fix it?
I have implemented a fully working example for anyone to try here.
application.conf
akka.http.server.idle-timeout = 5 s
akka.http.client.idle-timeout = 5 s
akka.http.server.request-timeout = 600 s
helloworld {
http {
interface = "127.0.0.1"
port = "8066"
}
}
Routes.scala
package com.codingkapoor.helloworld.http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.util.Timeout
import akka.stream.ActorMaterializer
import scala.concurrent.duration._
private[helloworld] trait Routes extends JsonSupport {
implicit lazy val timeout: Timeout = Timeout(5.minute)
implicit def materializer: ActorMaterializer
lazy val routes: Route = pathSingleSlash {
get {
Thread.sleep(180000)
complete(StatusCodes.OK, "Hello World!")
}
}
}