Levente
03/25/2021, 11:57 AMFábio Carneiro
03/25/2021, 2:56 PMDefaultWebSockerServerSession
is already a 1:1 connection between the server and client?Jordan Foo
03/25/2021, 7:04 PMDidier Villevalois
03/26/2021, 4:47 PMHttpClient
used by my OAuthAuthenticationProvider
. It correctly receives the access_token
.
Now my question is what to do from there. I did put all my routes (this app is fully private) in authenticate
, that is: my index /
route, my static /static
route (which serves the output.js
file of my app) and my /data
web-socket route.
However, it seems that every requests are handled by authentication
, the requests to /static/output.js
and to /static/favicon.ico
are all been redirected to keycloak and silently back to ktor. (The requests to my /data
websocket also hangs but...)
It seems to me that I should put the access_token
in my response as cookie or something in order for ktor to know it doesn't have to ask for a redirect. But it is not clear from the documentation what I should exactly do for authentication
to reuse the previously obtained access_token
.
Thanks in advance for your help.Arnau Miro
03/27/2021, 10:33 PMenvironment.monitor.subscribe(Routing.RoutingCallStarted) { call: RoutingApplicationCall ->
println("Route started: ${call.route}")
runBlocking { println(call.receiveText()) }
}
spierce7
03/28/2021, 3:51 PMadk
03/28/2021, 5:45 PMNikita Khlebushkin
03/30/2021, 12:33 PMRejecting re-init on previously-failed class java.lang.Class<okhttp3.internal.platform.ConscryptPlatform$platformTrustManager$2>: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/conscrypt/ConscryptHostnameVerifier;
Ktor 1.5.2, Android app with multiplatform networking librarySusheel
03/30/2021, 7:09 PMrnett
03/31/2021, 3:51 AMroute("{...}")
. However some of the functions make use of Ktor routing like authenticate
. This doesn't play nice with the routes because of ambiguity. If I put the authenticate and the handlers (w/ handle
) in the same route, the authenticate is always taken. If I each handler in it's own route("{...}")
, the sibling authenticate
is never taken. And even without that, if I have two of the same authenticates at the same level (one is optional, one isn't), the first is always taken. Is there a way to do something like this, i.e. have routes with fallthrough the request isn't handled? I'm currently using a RouteSelector
to do this, but it's quite a bit of overhead for something relative (at least conceptually) simple.Cyrille QUÉMIN
03/31/2021, 8:17 AMinstall(HttpTimeout) {
requestTimeoutMillis =
connectTimeoutMillis =
}
And
engine {
endpoint {
connectTimeout =
connectRetryAttempts =
}
requestTimeout =
}
In particular I could see the timeout from HttpTimeout
working but I could also see the default value of engine.requestTimeout
being used (before I changed it). Also, which connectTimeout
will be used ? HttpTimeout
of the one engine.endpoint
?
Note, I am using the CIO engine with Ktor 1.4.2Denis Ismailaj
04/02/2021, 10:31 AMJakob K
04/02/2021, 1:02 PMMichal Klimczak
04/04/2021, 6:15 PMByteReadChannel
and I have no idea why.
someCall()
.execute { response: HttpResponse ->
var offset = 0
val channel = response.receive<ByteReadChannel>()
val contentLen = response.contentLength()?.toInt() ?: 0
val temp = ByteArray(1024)
while (!channel.isClosedForRead) {
val read = channel.readAvailable(temp)
if (read <= 0) break
offset += read
println("$offset / $contentLen")
}
println("End: $offset / $contentLen")
...
94331817 / 94336479
94332841 / 94336479
94333857 / 94336479
End: 94333857 / 94336479
The worst part is that every time the result is a tiny bit different.
End: 94334201 / 94336479
End: 94334515 / 94336479
That's a simplified piece of code, normally I write to ios storage - it's a zip file and the checksum is wrong (although it seems to unzip fine, maybe one of many files is corrupt, dunno). When I download this file via browser, the checksum is fine.
ktor 1.5.3. Any ideas what I might be doing wrong?hhariri
04/05/2021, 12:32 PMhhariri
04/05/2021, 8:56 PMŁukasz Bednarczyk
04/06/2021, 7:38 AMklausner
04/06/2021, 5:46 PMAdd an option to disable URL Encoding
<https://youtrack.jetbrains.com/issue/KTOR-553>
This issue was imported from GitHub issue: <https://github.com/ktorio/ktor/issues/1351>
Subsystem ktor-client, ktor-http/common
Is your feature request related to a problem? Please describe. ktor-client cannot be used for URLs which are not supported by the URL Encoding format.
I failed to replace an HTTP client with ktor-client just because we needed to call a URL like /api?k1=v1;k1=v2 (non-encoded ; instead of %3B). As far as I checked, there's no way to bypass URL Encoding in ktor-client.
In other libraries, typically we can set parameters just like a simple Map<String, List<String>>. I agree that it's better to always use a sanitized request object, but it would be too strict not to have an option to disable encoding.
Describe the solution you'd like I opened a PR to add an option to bypass the URL Encoding when building a URL.
Motivation to include to ktor I believe that users of ktor-client shouldn't be blocked by the implementation of a server URL because they might not have control over it.
(Please let me know if there's an option to resolve the above problem.)
tim
04/07/2021, 3:22 PMchristophsturm
04/07/2021, 6:08 PM/**
* Register a route resolution trace function.
* See <https://ktor.io/servers/features/routing.html#tracing> for details
*/
public fun trace(block: (RoutingResolveTrace) -> Unit) {
tracers.add(block)
}
^ thats from the trace function in routing. sadly the link is a 404christophsturm
04/08/2021, 8:25 AMTrace for [api, weight]
/, segment:0 -> SUCCESS; Parameters [static-content-path-parameter=[api, weight]] @ ///{...}/(method:GET))
//, segment:0 -> SUCCESS; Parameters [static-content-path-parameter=[api, weight]] @ ///{...}/(method:GET))
///(method:GET), segment:0 -> FAILURE "Not all segments matched" @ ///(method:GET))
///{...}, segment:2 -> SUCCESS @ ///{...}/(method:GET))
///{...}/(method:GET), segment:2 -> SUCCESS @ ///{...}/(method:GET))
/api, segment:0 -> FAILURE "Lost in ambiguity tie" @ /api)
MBegemot
04/08/2021, 8:43 AMMarc Knaup
04/08/2021, 3:22 PMShan
04/08/2021, 8:34 PMJsonDecodingException
(from kotlinx.serialization) which I believe is being caused by the source string being cut off after decoding it to a String from a ByteArray
with the util extension function on ByteReadChannel
.
Unexpected JSON token at offset 195068: EOF JSON input: .....text !","field":0.0,"te
This particular error can only be thrown if the current position when iterating over the source string is >= the last index of the string, and my JSON is not being fully parsed, so I am assuming that the String is being truncated somehow before parsing.
...
.onSuccess { it: HttpResponse ->
val receiveString = it.content.toByteArray().decodeToString()
...
//later
return json.decodeFromString(receiveString) //cast to my return type T
}
Does anyone have any insight as to why this might be happening? Am I receiving my HttpResponse
content
incorrectly? Note: I'm not using the kotlinx JsonFeature
, using it separately.
My only idea right now is that it is failing to allocate the entire string due to OOM and this is just the first place exposing it, but I'm pretty sure this would fail with a different exception if that was the case. decodeToString()
is experimental but it was working as intended until very recently. I upgraded to Ktor 1.5.3 recently, but can't confirm that the version upgrade is what triggered it as I can't repro it locally, just see it in a crash report. It happens very infrequently, like ~.001% of all requests.okarm
04/09/2021, 12:40 PMHttpClient
is to be treated as a lightweight ephemeral object. Instantiating `HttpClient`s should be done liberally. HttpClient
itself is not resource heavy, all instances manage the underlying installed heavyweight engine in a manner consistent with the proper usage of that engine. Example: OkHttp
engine forks a statically allocated base OkHttpClient
by way of newBuilder()
. Same goes for other engines.
Is the above paragraph true? Assuming the clients are properly closed and all...Dominick
04/10/2021, 12:40 AMokarm
04/10/2021, 6:27 PMRuntimeException
?
Edit: nope, just found the BadContentTypeException : Exception
. try { client.request() } catch(e: Exception)
it is then.Harry B
04/11/2021, 3:00 PMclass example {
private val ktorClient = HttpClient(Js) {
install(WebSockets)
}
override suspend fun open() {
ktorClient.wss(
method = HttpMethod.Get,
host = "localhost",
port = 80, path = "/example"
) {
val frame = incoming.receive()
when (frame) {
is Frame.Text -> println(frame.readText())
is Frame.Binary -> println(frame.readBytes())
}
}
}
override fun close() {
TODO("Not yet implemented")
}
override fun <T> sendData(data: T) {
// Send to WS here
}
}
MBegemot
04/11/2021, 5:00 PMdave08
04/12/2021, 3:41 PMhandleRequest
have a way to handle requests to different ports (in the routing I have port(...) { ... }
)? (This is an older api that's running on Ktor version 1.3.0)dave08
04/12/2021, 3:41 PMhandleRequest
have a way to handle requests to different ports (in the routing I have port(...) { ... }
)? (This is an older api that's running on Ktor version 1.3.0)addHeader(HttpHeaders.Host, ":8050")