Skip to content

idleTimeout does not work with Jetty backend #3

Open
@mossprescott

Description

When a service yields a task that takes a long time to produce a response (see /slow in the code below), the Blaze backend will drop the socket after idleTimeout has elapsed. The Jetty backend:

  1. Keeps the connection open for 30 seconds, ignoring idleTimeout.
  2. Then returns a 200 OK with no body.
import scala.concurrent.duration._

import scalaz.concurrent._

import org.http4s.dsl._
import org.http4s.server._

object JettyTest extends App {
  val service = HttpService {
    case GET -> Root / "slow" => for {
      _    <- Task.delay { Thread.sleep(45*1000) }
      resp <- InternalServerError("finally!")
    } yield resp

    case GET -> Root / "fail" => Task.fail(new RuntimeException)
  }

  val js = org.http4s.server.jetty.JettyBuilder
    .withIdleTimeout(1.second)
    .bindHttp(8080, "0.0.0.0")
    .mountService(service)

  val bs = org.http4s.server.blaze.BlazeBuilder
    .withIdleTimeout(1.second)
    .bindHttp(8180, "0.0.0.0")
    .mountService(service)

  js.run
  bs.run
}

Using http4s 0.8.2.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions