Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Sep 27 12:08
    kink80 commented #1067
  • Sep 27 12:05
    kink80 opened #1119
  • Sep 25 18:29
    mergify[bot] labeled #1118
  • Sep 25 18:28
    scala-steward closed #1108
  • Sep 25 18:28
    scala-steward commented #1108
  • Sep 25 18:28
    scala-steward opened #1118
  • Sep 24 14:57
    mergify[bot] labeled #1117
  • Sep 24 14:57
    scala-steward opened #1117
  • Sep 24 08:41

    mergify[bot] on empty-gzip-fix


  • Sep 24 08:40
    adamw commented #1113
  • Sep 24 08:40

    adamw on master

    Added test to reproduce excepti… Fixed exception for empty gzipp… Fixed handling of empty gziped … and 4 more (compare)

  • Sep 24 08:40
    adamw closed #1113
  • Sep 24 08:40
    adamw closed #1065
  • Sep 24 01:23

    mergify[bot] on master

    Update fs2-core, fs2-io, ... to… Merge pull request #1116 from s… (compare)

  • Sep 24 01:23
    mergify[bot] closed #1116
  • Sep 24 00:55
    mergify[bot] labeled #1116
  • Sep 24 00:54
    scala-steward opened #1116
  • Sep 23 15:03
    adamw commented #1115
  • Sep 22 19:16
    adamw commented #1003
  • Sep 22 19:11
    nickrobison edited #1115
Glen Marchesani
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.

1 reply