HttpClient backend (Java 11+)

To use, add the following dependency to your project:

"com.softwaremill.sttp.client" %% "httpclient-backend" % "2.0.0-RC6"

This backend is based on available from Java 11 onwards and offers:

  • a synchronous backend: HttpClientSyncBackend
  • an asynchronous, Future-based backend: HttpClientFutureBackend
  • an asynchronous, Monix-Task-based backend: HttpClientMonixBackend with streaming support


The HttpClient backend supports websockets, where the websocket handler is of type sttp.client.httpclient.WebSocketHandler. An instance of this handler can be created in two ways.

The first (“high-level”), available when using the Monix variant, is to pass a MonixWebSocketHandler(). This will create a websocket handler and expose a[Task] interface for sending/receiving messages.

See websockets for details on how to use the high-level interface.

Second (“low-level”), given an HttpClient-native, you can lift it to a web socket handler using WebSocketHandler.fromListener. This listener will receive lifecycle callbacks, as well as a callback each time a message is received. Note that the callbacks will be executed on the Netty (network) thread, so make sure not to run any blocking operations there, and delegate to other executors/thread pools if necessary. The value returned in the WebSocketResponse will be an instance of, which allows sending messages.