Override "timely response" error page?


is it possible to override the “timely response” error page ?

Hi @0xbaadf00d,

We currently don’t have a way to do that. This response is being returned by Akka HTTP itself, without triggering Play’s error handler. A possible workaround is combine HTTP Filters with a future timeout:

import akka.stream._
import javax.inject._

import play.api.mvc._
import play.api.libs.concurrent.Futures._

import scala.concurrent._
import scala.concurrent.duration._

class TimeoutFilter @Inject() (implicit val mat: Materializer, ec: ExecutionContext) extends Filter {
  override def apply(next: RequestHeader => Future[Result])(rh: RequestHeader): Future[Result] = {
    next(rh).withTimeout(10.seconds).recover {
      case _: TimeoutException => Results.GatewayTimeout("Oops, take too long!")

Anyway, we are constantly improving the integration between Akka HTTP and Play and I think it makes sense to have some way to translate Play’s error handler to Akka HTTP. @richdougherty probably has some thoughts here too.


1 Like

I agree with @marcospereira’s suggestion. Disable the Akka HTTP timeouts and use a filter in Play. I wrote something similar here, but Marcos’s suggestion is more concise.

Thanks @richdougherty. however, is it possible to change the AKKA “timeout” value to “never” or a big value ?

yes it’s possible to do it. you can set it to "infinite" or null. But that is actually the default, so basically you can either remove any custom setting of play.server.akka.requestTimeout or if you prefer to set it, you can just set it to either null or "infinite"

Strange behavior, if infinite is the default, why the “timely” error occurred? (Project is using Play 2.6.9)

you should upgrade to play 2.6.13, there was a bug, where the infinite did not work. (Fix was in 2.6.11)

great, thanks