Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Sep 21 16:17

    mergify[bot] on master

    Update http4s-blaze-client, htt… Merge pull request #1114 from s… (compare)

  • Sep 21 16:17
    mergify[bot] closed #1114
  • Sep 21 15:47
    mergify[bot] labeled #1114
  • Sep 21 15:47
    scala-steward opened #1114
  • Sep 21 13:35
    bartekzylinski review_requested #1113
  • Sep 21 13:35
    bartekzylinski assigned #1113
  • Sep 21 13:35
    bartekzylinski opened #1113
  • Sep 21 13:33

    bartekzylinski on empty-gzip-fix

    Added test to reproduce excepti… Fixed exception for empty gzipp… (compare)

  • Sep 21 13:13

    mergify[bot] on master

    Update http4s-blaze-client, htt… Merge pull request #1112 from s… (compare)

  • Sep 21 13:13
    mergify[bot] closed #1112
  • Sep 21 12:45
    mergify[bot] labeled #1112
  • Sep 21 12:44
    scala-steward opened #1112
  • Sep 21 01:54

    mergify[bot] on master

    Update zio, zio-streams to 1.0.… Merge pull request #1111 from s… (compare)

  • Sep 21 01:54
    mergify[bot] closed #1111
  • Sep 21 01:22
    mergify[bot] labeled #1111
  • Sep 21 01:21
    scala-steward opened #1111
  • Sep 20 07:20
    bartekzylinski assigned #1065
  • Sep 18 06:58

    mergify[bot] on master

    Update cats-effect, cats-effect… Merge pull request #1110 from s… (compare)

  • Sep 18 06:58
    mergify[bot] closed #1110
  • Sep 18 06:24
    mergify[bot] labeled #1110
Glen Marchesani
import sttp.client3._
I think should do it for you
Yep - that did it! Thank you.
Andrii Ilin
Hi, guys.
Where can I find some kind of compatibility matrix for sttp-model, getting NoClassDefFound when try to use tapir 0.15.x and sttp client3 in the same project?
1 reply

Hi, guys.
Where can I find some kind of compatibility matrix for sttp-model, getting NoClassDefFound when try to use tapir 0.15.x and sttp client3 in the same project?

Faced same in our projects
Concrete classes:

  1. MediaType.copy
    https://www.javadoc.io/doc/com.softwaremill.sttp.model/core_2.12/1.4.0/sttp/model/MediaType.html. vs

  2. Uri (host: String vs host: Option[String])

@adamw I think it's time to release core v2 with new package names to achieve compatibility between v2 and v3
at the same time you may want to consider using MIMA?

4 replies

is it cheating to do

.response(asStream(MonixStreams)(i => Task(i)))

instead of



1 reply
Glen Marchesani
I am trying to limit the total number of http connections at any given moment. Is there an idiomatic way to do this ? I tried using the AsyncHttpCLient setting for that BUT the AsyncHttpClient appears to fail when you meet that number instead of waiting for a connection...
11:23:50.465 | DEBUG | 18 | a8.sync.http | http request failed on the 2 retry -- https://rm-api-dev-1-ext.goodville-dev.assure.dxc.com/riskmasterapi/events/34864/claimgc/12420/claimants - (http.scala:42)
sttp.client3.SttpClientException$ReadException: Exception when sending request: GET https://rm-api-dev-1-ext.goodville-dev.assure.dxc.com/riskmasterapi/events/34864/claimgc/12420/claimants
    at sttp.client3.SttpClientException$.defaultExceptionToSttpClientException(SttpClientException.scala:44)
    at sttp.client3.asynchttpclient.AsyncHttpClientBackend.$anonfun$adjustExceptions$1(AsyncHttpClientBackend.scala:227)
    at sttp.client3.SttpClientException$$anonfun$adjustExceptions$1.applyOrElse(SttpClientException.scala:57)
    at sttp.client3.SttpClientException$$anonfun$adjustExceptions$1.applyOrElse(SttpClientException.scala:56)
    at cats.ApplicativeError.$anonfun$recoverWith$1(ApplicativeError.scala:106)
    at cats.effect.IOFiber.handleErrorWithK(IOFiber.scala:1283)
    at cats.effect.IOFiber.failed(IOFiber.scala:1057)
    at cats.effect.IOFiber.uncancelableFailureK(IOFiber.scala:1308)
    at cats.effect.IOFiber.failed(IOFiber.scala:1059)
    at cats.effect.IOFiber.onCancelFailureK(IOFiber.scala:1296)
    at cats.effect.IOFiber.failed(IOFiber.scala:1058)
    at cats.effect.IOFiber.unmaskFailureK(IOFiber.scala:1318)
    at cats.effect.IOFiber.failed(IOFiber.scala:1060)
    at cats.effect.IOFiber.onCancelFailureK(IOFiber.scala:1296)
    at cats.effect.IOFiber.failed(IOFiber.scala:1058)
    at cats.effect.IOFiber.runLoop(IOFiber.scala:752)
    at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1132)
    at cats.effect.IOFiber.run(IOFiber.scala:126)
    at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:359)
Caused by: org.asynchttpclient.exception.TooManyConnectionsException: Too many connections: 20
anyone have any recommendations on how to do this in a composable way...
I could hack this to make it work inside our retry framework but I am figuring someone has had to do this already
hmm even simpler I can just wrap my use in a semaphore
3 replies
Glen Marchesani
nm and thanks for listening

Hi ,
I am trying to stub a response to be used in a asStreamUnsafe response.
When using a asByteArray response the stub is working.

When using the a asStreamUnsafe response
I am getting

An unchecked error was produced.
java.lang.ClassCastException: [B incompatible with scala.util.Either

I have prepared a scastie similar to what I am doing. https://scastie.scala-lang.org/QOf83EyOSZCQsfnGoZrUPg
The only difference is that instead of a typed error I am using a throwable in scastie.

and the error in scastie is

An unchecked error was produced.
java.lang.ClassCastException: java.lang.String cannot be cast to scala.util.Either

I am not sure if it is related to softwaremill/sttp#389, and is a similar thing that has to do with the stub
or if I am doing something wrong ?

Any help would be appreciated.

Stubbing works for asStreamAlwaysUnsafe and when stubbing with .thenRespond(Response.ok(ZStream.fromIterable("Stub response".getBytes)))
( I have updated the scastie link)
What would be the correct way to stub for asStreamUnsafe ?
7 replies
Jeremiah Malina

I'm trying to upgrade a spark app from Scala 2.11 to Scala 2.12 (I know it's old..) but currently running into this issue on sttp 2.2.9:

java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)V
    at sttp.client.SttpBackendOptions.<init>(SttpBackendOptions.scala:12)
    at sttp.client.SttpBackendOptions$.<init>(SttpBackendOptions.scala:100)
    at sttp.client.SttpBackendOptions$.<clinit>(SttpBackendOptions.scala)
    at sttp.client.HttpURLConnectionBackend$.apply$default$1(HttpURLConnectionBackend.scala:308)
    at com.newscred.services.NewsCredAnalyticsAPIClient.<init>(NewsCredAnalyticsAPI.scala:46)

The offending line of code is implicit var backend = HttpURLConnectionBackend()
Anyone have an idea what the issue might be? Thanks in advance :)

@jjmalina: usually , when NoSuchMethodError happens, it is a mixup with library versions.
you can use sbt dependencyTree to see the versions of the library in question, and then use exclude in build.sbt exclude transitive dependencies
Jeremiah Malina
@harrylaou:matrix.org thanks! how do I know which transitive dependencies to exclude? is it correct to assume that the java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;) error implies that the wrong version of scala is being used somehow?
it looks like everything is ok with scala 2.12
Jeremiah Malina
Turns out that the issue was that I was running my app in EMR on Spark which was running Scala 2.11, upgraded EMR and it solved the error I got with sttp, though now I'm having a similar error with json4s :/
Saad Khawaja
The sttp doc page here https://sttp.softwaremill.com/en/latest/backends/http4s.html ask to use "com.softwaremill.sttp.client3" %% "http4s-backend" % "3.3.6" but this is not in maven central. Where could this be found. Thanks.
8 replies
Philippe Derome
I’ve been toying with WebSocketZio and WebSocketStreamFs2 examples and I see the Fs2 example uses API asWebSocketStream which is quite nice and useful and the Zio one uses asWebSocketAlways which while useful is a bit less interesting. Would it make sense to extend both examples to achieve some parity on API usage (i.e. both using asWebSocketStream and asWebSocketAlways)? I didn’t look at the Akka example mind you.
4 replies
If there’s some interest, I could do a PR to add asWebSocketStream to th ZIO solution.
Philippe Derome
Ashwin Bhaskar
How can I mock requests and response when using AsyncHttpClientZioBackend.stubLayer? When using AsyncHttpClientZioBackend.stub I could do AsyncHttpClientZioBackend.stub.whenRequestMatches(...).thenResponse(...).
2 replies
Łukasz Drygała
Hi guys, I would like to test a client that streams data from a websocket. Unfortunately, it fails with class sttp.ws.testing.WebSocketStub cannot be cast to class akka.stream.scaladsl.Flow (sttp.ws.testing.WebSocketStub and akka.stream.scaladsl.Flow are in unnamed module of loader 'app')
4 replies
Ashwin Bhaskar
Is there an equivalent of akka.http.scaladsl.model.Uri's parseAndResolve for sttp.model.Uri?
1 reply
How can I get BinaryStream from
(sttp.capabilities.Streams[sttp.capabilities.zio.ZioStreams] & Singleton)# BinaryStream?
I have:
val fileStream: (Streams[ZioStreams] & Singleton)#BinaryStream <- sttpClient

uploadRequest = basicRequest.streamBody(ZioStreams)(fileStream)
Found:    (fileStream : 
  (sttp.capabilities.Streams[sttp.capabilities.zio.ZioStreams] & Singleton)#
Required: sttp.capabilities.zio.ZioStreams.BinaryStream²

where:    BinaryStream  is a type in class Streams with bounds 
          BinaryStream² is a type in trait ZioStreams which is an alias of zio.stream.Stream[Throwable, Byte]
So error is in basicRequest.streamBody(ZioStreams)(fileStream)
9 replies
The latest tapir 0.18.0 is CE2-only compatible and its http4s module depends on http4s 0.22.0-RC1, while sttp 3.3.9 CE2 http4s module depends on http4s 0.21.x, so they are incompatible. It may be force-fixed in sbt but the risk of runtime bincompat issues is high
6 replies

Hi, I'm getting some weird EOF error from sttp that I'm unsure about.

o.h.b.p.Command$EOF$: EOF

logger_name: "sttp.client3.logging.slf4j.Slf4jLoggingBackend"
logger_name: "sttp.tapir.server.http4s.Http4sServerInterpreter"

I'm using sttp client version 3.2.3. Does anyone know what might be causing this and how to resolve it?

3 replies
@adamw for those who's still on CE2, can we have constistent versions of tapir 0.18.x and sttp 3.3.x compatible with each other and http4s 0.22.0 ?
8 replies
Julien Richard-Foy
Hello! What is the versioning scheme used by sttp? Are all the minor releases backward binary compatible? Are all the patch releases backward source compatible?
6 replies
Hi qq: Is there a zio integration with FetchBackend for scalajs?
2 replies
Looking for something like AsyncZioHttpBackend but for scalajs
Colin Aygalinc

Hi, I'm getting weird behavior with AkkaSttpBackend & retry when one of the service I rely is down.
I have draw a small test case :
"When constraint server is in error then we " should " get an error when asking for constraint" in {
val sttp = AkkaHttpBackend()

val request: () => Future[String] = () => {
  println("Launch some stuff")
  val startTime = System.currentTimeMillis()

    .recoverWith {
      case error => {

        println(s"${System.currentTimeMillis() - startTime} millis")


implicit val successForFuture: Success[String] = Success.always

recoverToSucceededIf[SttpClientException] {
  val response = retry.Pause(max = 3, delay = 20.milliseconds).apply {


What I observe is inconsistent timeout for detecting the failure : 4366 millis - 200920 millis - 117760 millis - 138533 millis
So basically error detection occurs btw ' seconds to more than 3 minutes
Colin Aygalinc
I expect that the detection of this error would be quicker or at least take the Default 30 second of timeout no ?
I am struggling to POST with a simple payload in json using sttp. Wondering if anyone can help me correct what I'm doing wrong. I get a response back that the payload is invalid. I can also see the curl equivalent of my request and it's not what I intend as the data is not being sent as json
def sendMessage(message: String): Unit = {
    val request = basicRequest
      .contentType(ct = "application/json")
      .body(Map("text" -> message))
      .post(uri"<URI goes here>")

    request.send().body match {
      case Left(error) => logger.error(s"Could not send message: $message due to $error")
      case Right(_) => ()
3 replies
Mike Limansky

Hi. I'm pretty new both to sttp and zio, so my question might be pretty simple, however I've got stuck with testing.

I've created a service which uses SttpClient. I'd like to test it. So I create service like:

val myService = (ZLayer.succeed(Config("1234", "abc")) ++ HttpClientZioBackend.stubLayer) >>> MyService.live

val stubEffect = for {
        _ <- whenRequestMatches(_.uri.toString().endsWith("/api/v1/doit")).thenRespond("response")
      } yield ()

val result = for {
        a <- MyService.doIt("Some input")
      } yield assert(a)(isRight(equalTo("response")))


What is not clear is how to pass the stubFffect to provide a mocked server response. Are there any examples?

5 replies
Fredrik Wärnsberg
What happened to https://github.com/softwaremill/sttp/issues/451#issuecomment-675533291 ? I can't seem to find failLeft anywhere in the code base.
2 replies
Swoorup Joshi
what is the equivalent package for sttp.tapir.server.stub.*?
in scala 3
1 reply
I'm trying to migrate from sttp client 2 to client3, but my linter fails on Any. I don't want to turn this off, but I'd really rather not add ignore annotations to some 40-odd endpoints. Is there some version of a no-op stream type I can use instead of Any?
6 replies
Nick Robison

Hi folks, I had a quick question regarding the streaming functionality of the Zio backend:

I have the following code that I'm attempting to use to return the http response stream to the caller:

          .method(Method(proxyRequest.method.value), uri)
          .headers(proxyRequest.headers.map(h => Header(h.name(), h.value())): _*)

The response type is Request[Either[String, BinaryStream]; however, when I attempt to run the code, I get the following error:

class zio.stream.ZStream$$anon$1 cannot be cast to class scala.util.Either

The caller looks like this: client.send(req).map(_.body)

I'm sure there are a couple of things that I'm doing wrong, but I'm stumped as to why the types don't seem to line up with the actual implementation.