Tapir/ sttp scala.js websockets support status

Hi,

I’m currently trying to connect to a websocket endpoint, described with tapir, using a scala.js client.

According to the docs ( Scala.js (Fetch) backend — sttp 4 documentation ), it can be done with Monix. Unfortunately, Monix does not seem to be maintained anymore and it’s associated library monix-catnap is not compatible with cats-effects 3.x

I’ve tried FS2 (at the beginning), but HttpClientFs2Backend seems to be only available for JVM. I guess it’s because fs2-reactive-streams is built with a dependency on org.reactivestreams that has not been published for scala.js ( Version 1.0 by alexandru · Pull Request #1 · reactive-streams/reactive-streams-scalajs · GitHub )

Is there another backend that supports websockets on scala.js?

Regards,

The FetchCatsBackend is probably what you’re after? Scala.js (Fetch) backend — sttp 4 documentation

It does support web sockets - though not the streaming ones. You can use a WebSocket[IO] though.

For streaming ws, we’d need a FetchFs2Backend, which we don’t have. HttpClientFs2Backend is based on Java’s HttpClient, so it’s naturally JVM-only.

Thanks for the answer.
You’re right, I’ve seen afterward that my need was not the WS but streaming support in the context of a WS.
I’ve used http4s-dom directly in my scala.js client and kept the tapir description only server-side.

1 Like