BlazeClient: requestTimeout is not enforced
See original GitHub issueProblem 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:
- Created 5 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
There is a new version 1.3.0 of cats-effect that was released today!