mergify[bot] on master
Update http4s-client to 0.23.12 Merge pull request #1447 from s… (compare)
mergify[bot] on master
Update http4s-blaze-client to 0… Merge pull request #1448 from s… (compare)
magdzikk on v2-update-version-in-docs
Update version in docs for v2 … (compare)
mergify[bot] on master
Update scribe to 3.8.3 Merge pull request #1445 from s… (compare)
mergify[bot] on master
Update cats-effect, cats-effect… Merge pull request #1444 from s… (compare)
val wsBuilder = client.newWebSocketBuilder()
client.connectTimeout().map[java.net.http.WebSocket.Builder](wsBuilder.connectTimeout(_))
request.headers.foreach(h => wsBuilder.header(h.name, h.value))
val cf = wsBuilder
.buildAsync(request.uri.toJavaUri, listener)
.thenApply[Unit](_ => ())
.exceptionally(t => cb(Left(t)))
Canceler(() => cf.cancel(true))
})
wsBuilder.subprotocols
afaik
SttpBackend
trait, the documentation for send
states Type parameters: R – The capabilities required by the request. This must be a subset of the the capabilities supported by the backend (which always includes Effect[F]).
, which makes sense. However when I'm looking at AkkaHttpBackend
, the type returned is SttpBackend[Future, AkkaStreams with WebSockets]
, so Effect[Future]
is not included. Shouldn't that be there?
I'm currently idiot-testing 3.0.0's akka websockets, so I created a minimal build.sbt and copy pasted this example:
https://sttp.softwaremill.com/en/latest/examples.html#open-a-websocket-using-akka
It doesn't compile! It complains:
Symbol 'type akka.event.LoggingAdapter' is missing from the classpath.
This symbol is required by 'value sttp.client3.akkahttp.AkkaHttpBackend.customLog'.
Make sure that type LoggingAdapter is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
The akka documentation says for logging you need: "com.typesafe.akka" %% "akka-actor" % "2.6.10"
However, I saw that sttp3's akka-http-backend has this listed as provided
so I went with that instead: "com.typesafe.akka" %% "akka-stream" % "2.6.10"
It compiles, but I get 0 output when I run the example. No error, no nothing.
build.sbt:
name := "meep"
scalaVersion := "2.13.4"
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client3" %% "core" % "3.0.0",
"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.0.0",
"com.typesafe.akka" %% "akka-stream" % "2.6.10"
)
Playing this game with the monix example, I get this SSL exception when running:
runMain sttp.client3.examples.WebSocketMonix
[info] running sttp.client3.examples.WebSocketMonix
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[error] (run-main-4) sttp.client3.SttpClientException$ConnectException: Exception when sending request: GET wss://echo.websocket.org
[error] sttp.client3.SttpClientException$ConnectException: Exception when sending request: GET wss://echo.websocket.org
[error] Caused by: java.net.ConnectException: handshake timed out after 10000ms
[error] Caused by: io.netty.handler.ssl.SslHandshakeTimeoutException: handshake timed out after 10000ms
(I've omitted the stack trace elements in between due to gitter's message limits)
Hi guys, I'm seeing a very strange issue when using sttp as a web socket client:
basicRequest.auth
.basic(username, password)
.response(asWebSocketStream(Fs2Streams[F])(webSocketFramePipe(q)))
.get(uri)
.send(backend)
.void
Sometimes I'm seeing this exception when running the above code:
sttp.client3.DeserializationException: exhausted input
I'm suspecting this is an upstream server issue (it gets resolved when they restart it). On the other side using python I can connect without those issues. Anybody has seen something similar or has a hint on how to trace it down?
Defect in zio.Has: Set(SttpBackend[=λ %2:0 → ZIO[-Any,+Throwable,+2:0],+{ZioStreams & package::WebSockets}])
mentioned above. I'm just not sure why, because I think I'm using the right versions (sttp = 3.0.0, zio = 1.0.3, tapir = 0.17.7). Any ideas?
v2
missing.
String
urls until this is fixed?
Not in gzip format
. This is presumably because STTP is attempting to decompress what has already been decompressed by the http4s middleware. This suggests that backends shouldn't do their own decompression, is that true?
send
method from sttp.client3.asynchttpclient.zio._
package to make the request. But when I am trying to write unit test cases for that, I found https://sttp.softwaremill.com/en/latest/testing.html send(backEnd)
method with passing backend. I check, there is stubbing
in sttp.client3.asynchttpclient
package, but not sure, is it used for unit test our not? Another question, Do we have predefined ZIO backend
or we need to define our own? for passing into the send(...)
method.
Hi all. I couldn't find in sttp documentation if it is possible to describe a google batch request with sttp.
https://developers.google.com/gmail/api/guides/batch#batch-example-request
POST /batch/farm/v1 HTTP/1.1
Authorization: Bearer your_auth_token
Host: www.googleapis.com
Content-Type: multipart/mixed; boundary=batch_foobarbaz
Content-Length: total_content_length
--batch_foobarbaz
Content-Type: application/http
Content-ID: <item1:12930812@barnyard.example.com>
GET /farm/v1/animals/pony
--batch_foobarbaz
Content-Type: application/http
Content-ID: <item2:12930812@barnyard.example.com>
PUT /farm/v1/animals/sheep
Content-Type: application/json
Content-Length: part_content_length
If-Match: "etag/sheep"
{
"animalName": "sheep",
"animalAge": "5"
"peltColor": "green",
}
--batch_foobarbaz
Content-Type: application/http
Content-ID: <item3:12930812@barnyard.example.com>
GET /farm/v1/animals
If-None-Match: "etag/animals"
--batch_foobarbaz--
Is there a way to call google batch api with sttp client?
multipartBody
, but I couldn't find a way how to set an url for each part
java.net.UnknownHostException: my.valid.host.com : nodename nor servname provided, or not known
ok I did a bit of investigation and here's where I am at the moment:
No WebSocketUpgradeHandler but scheme is ws
java.lang.IllegalArgumentException: No WebSocketUpgradeHandler but scheme is ws
at org.asynchttpclient.netty.request.NettyRequestSender.validateWebSocketRequest(NettyRequestSender.java:571)
at org.asynchttpclient.netty.request.NettyRequestSender.sendRequest(NettyRequestSender.java:95)
at org.asynchttpclient.DefaultAsyncHttpClient.execute(DefaultAsyncHttpClient.java:259)
at org.asynchttpclient.DefaultAsyncHttpClient.executeRequest(DefaultAsyncHttpClient.java:228)
at org.asynchttpclient.BoundRequestBuilder.execute(BoundRequestBuilder.java:35)
at sttp.client3.asynchttpclient.AsyncHttpClientBackend.$anonfun$sendRegular$1(AsyncHttpClientBackend.scala:59)
at sttp.client3.impl.monix.TaskMonadAsyncError$.$anonfun$async$1(TaskMonadAsyncError.scala:18)
at cancelable @ sttp.client3.impl.monix.TaskMonadAsyncError$.async(TaskMonadAsyncError.scala:17)
I get that ^^ my code is:
uri.flatMap[Vector[String]] { uri =>
AsyncHttpClientMonixBackend()
.flatMap { backend =>
basicRequest
.get(Uri(uri))
.body(msg)
.send(backend)
.flatMapLoop(Vector.empty[String]) { (each, acc: Vector[String], continue) =>
Task
.fromEither[String, String] { e: String => new Exception(e) }(each.body)
.flatMap { response =>
val newList = acc :+ response
if (terminateOn(newList))
continue(newList)
else Task.pure(newList)
}
}
.guarantee(backend.close())
}
}
uri.flatMap[Response[Either[String, Vector[String]]]] { uri =>
AsyncHttpClientMonixBackend()
.flatMap { backend =>
basicRequest
.get(Uri(uri))
.body(msg)
.response(
asWebSocket((f: WebSocket[Task]) =>
f.sendText(msg) *> f.receiveText().flatMapLoop(Vector.empty[String]) { (each, acc, continue) =>
val nAcc = acc :+ each
println(nAcc)
if (terminateOn(nAcc)) {
Task.pure(nAcc)
} else continue(nAcc)
}
)
)
.send(backend)
}
}
def uploadFile[T](
url: String,
file: File,
headers: Map[String, String],
responseMapper: String => T
): Task[T] =
for {
request <- Task.effect(
basicRequest
.body(file)
.readTimeout(2.minutes)
.put(uri"$url")
.headers(headers)
)
result <- send(request)
.provideLayer(sttpBackendLayer)
.flatMap { response =>
if (response.isSuccess)
response.body.fold(
error => Task.fail(new RuntimeException(error)),
stringRes => Task.effect(responseMapper(stringRes))
)
else Task.fail(new RuntimeException(response.statusText))
}
} yield result