question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlazeClient: requestTimeout is not enforced

See original GitHub issue

Problem Description

requestTimeout in BlazeClient is not enforced on certain requests.

Expected behavior: A timeout exception is thrown after 1 second.

Actual behavior: The request seems to be stuck indefinitely.

Related issues: #2338 (almost certainly the same source of the problem)

Source

Main.scala

import cats.effect._
import org.http4s._
import org.http4s.client.blaze.BlazeClientBuilder

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

object Main extends IOApp {

  override def run(args: List[String]): IO[ExitCode] = for {
    c <- BlazeClientBuilder[IO](ExecutionContext.global)
        .withRequestTimeout(1.second)
        .resource
        .allocated
    (client, _) = c
    _ <- IO { println("Sending a request.") }
    _ <- client.fetch(Request[IO](Method.GET, Uri.unsafeFromString("http://1.2.3.4:12345/")))(_ => IO.unit)
    _ <- IO { println("Got a response.") }
  } yield ExitCode.Success
}

build.sbt

name := "http4s-client-request-timeout-bug"

version := "0.1"

scalaVersion := "2.12.8"

libraryDependencies ++= Seq(
  "org.typelevel" %% "cats-core" % "1.5.0",
  "org.typelevel" %% "cats-effect" % "1.1.0",
  "org.http4s" %% "http4s-blaze-client" % "0.20.0-M5"
)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
RafalSumislawskicommented, Apr 27, 2019

The fix for typelevel/cats-effect#499 is in master, but there was no release since it was merged. I’ll take care of removing the workaround code once a fixed casts-effect version is available.

1reaction
anilkumarmylacommented, May 2, 2019

There is a new version 1.3.0 of cats-effect that was released today!

Read more comments on GitHub >

github_iconTop Results From Across the Web

http4s/http4s - Gitter
Hey all - I want to send a post request with no body using the blaze client but its giving the error: org.http4s.MalformedMessageBodyFailure:...
Read more >
Http4s Blaze Client Builder wait queue full failure
I am not sure if this happens when the outbound HTTP request is slow or times out. There is a possibility that the...
Read more >
Http4s backend — sttp 3 documentation - SoftwareMill
Instead, all custom timeout configuration should be done by creating a org.http4s.client.Client[F] , using e.g. org.http4s.client.blaze.BlazeClientBuilder[F] ...
Read more >
Changelog - http4s
Fix request logger to log in the case of no request body, ... #4831: Fix blaze-client handling of early responses; #4958: Reuse idle...
Read more >
The JMeter HTTP Request: How and When to Use It
If you want to set a connection and response timeout, set the Timeouts (milliseconds) option. If you execute an HTTP request and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found