Julien Salvi
01/25/2021, 11:57 AMPatrick Doering
01/25/2021, 6:35 PMjvmusin
01/26/2021, 12:20 PMdelay
for some time (say 20 seconds) and then respond with a string.
I thought that when I call delay
, I can serve other requests while previous requests are suspended, but instead, I have to wait until those requests are done and only then I'm able to serve new requests.
How can I serve new requests when my previous requests are suspended? I thought it works like that by default, but now I really don't understand.hellman
01/27/2021, 11:59 AMhellman
01/27/2021, 4:34 PMGus
01/27/2021, 5:48 PMjava.io.IOException:
at sun.nio.ch.IOUtil.makePipe (Native Method)
at sun.nio.ch.PollSelectorImpl.<init> (PollSelectorImpl.java:57)
at sun.nio.ch.PollSelectorProvider.openSelector (PollSelectorProvider.java:36)
at io.ktor.network.selector.ActorSelectorManager$1.invokeSuspend (ActorSelectorManager.kt:41)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:665)
And to make matters worse, the user who experienced it sent the crash report to Google Play Store anonymously, so I can't contact them to ask for more info. I can't reproduce it either (even though I coincidentally have the same phone). Any thoughts on how to get to the bottom of this? It seems like it's happened 5 times to the same user (we're running a beta right now, so it may be a big issue when we eventually launch).
I'm using Ktor via a library. Behind the scenes, that library keeps a WebSocket open and makes some POST
requests when certain events happen. I can see that the library is properly handling `IOException`s in WebSocket and HTTP connections.John O'Reilly
01/27/2021, 8:07 PMArkangel
01/28/2021, 10:51 AMedenman
01/28/2021, 7:52 PMResponseException
has an HttpResponse
on it, but it looks like by the time I catch
that exception, the response has already been consumed. I want to parse the json on the response, what’s the best way to do that?robnik
01/29/2021, 1:23 AMCheenu Soni
01/29/2021, 2:29 AMCould not get unknown property 'kotlin_serialization' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
while importing this dependency
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialization"
Cheenu Soni
01/29/2021, 7:37 AMhellman
01/29/2021, 3:25 PMexpectSuccess
to false
. But if I do that, I can’t get the deserialized body.
This means that when I get a valid response, like 302 Found
, I still get an exception.
How is this meant to be used?Allen Eubank
01/29/2021, 4:48 PM/** Application.main() */
val db: SqlDelightDatabase by inject()
val orgDb: OrgDb by inject()
install(Authentication) {
basic(name = "orgtoken") {
validate { credentials ->
if (credentials.name.isEmpty() or credentials.name.isEmpty()) return@validate null
val org = db.organizationQueries.selectByHttpAuthUsername(credentials.name)
.executeAsOneOrNull() ?: return@validate null
val orgQueries = orgDb.instance(org) ?: return@validate null
val activeToken = orgQueries.tokenQueries.validToken(credentials.password).executeAsOne()
if (activeToken) {
return@validate OrganizationPrincipal(org)
} else {
return@validate null
}
}
}
}
Poohrang
01/29/2021, 7:49 PMRohde Fischer
01/30/2021, 2:07 PMException in thread "main" java.lang.AbstractMethodError: io.ktor.server.engine.ApplicationEngineEnvironmentReloading.getDevelopmentMode()Z
at io.ktor.application.Application.<init>(Application.kt:20)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:269)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:125)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:245)
at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:126)
at io.ktor.server.netty.EngineMain.main(EngineMain.kt:26)
not sure where to go from here? This error isn't that descriptiveCheenu Soni
02/01/2021, 3:46 AMRohde Fischer
02/01/2021, 7:36 AMFooRoute
and want to make use of the FooService
interface, what is a reasonable way to do that? Currently I'm around:
class FooRoute @Inject constructor(application: Application, foo: FooService) {
init {
// do "magic" here
}
}
but I also want to structure my code in nicely designed methods etc. so there's a clear structure to it and all thatIfvwm
02/01/2021, 9:59 AMmelatonina
02/01/2021, 10:10 AMJgafner
02/01/2021, 3:10 PMEvan
02/02/2021, 12:52 AMktorClient.get<Something>
and see the request logged, but the ktor client gets blocked and the ktor function never returns. As such the test hangs forever.
The application runs fine normally.Azur Haljeta
02/02/2021, 3:11 PMHttpResponseValidator{}
doesn't work anymore in 1.5.0, why? It doesn't get called at all
https://ktor.io/docs/response-validation.htmlhhariri
02/03/2021, 11:51 AMBig Chungus
02/03/2021, 2:28 PMimport kotlinx.serialization.*
@Serializable
data class PagedResponse<T>(
val data: List<T>,
val total: Int,
val next: String?,
val prev: String?,
)
And when I fetch something from the backed via ktor client I get this (request itself is successful and that same class is serialized on the backand fine):
ERROR[]: Can't find a method to construct serializer for type PagedResponse. Make sure this class is marked as @Serializable or provide serializer explicitly.
Any ideas anyone?? I'm completely lost...hhariri
02/03/2021, 5:24 PMOrhan Tozan
02/03/2021, 10:34 PMJgafner
02/04/2021, 9:55 AMandylamax
02/05/2021, 7:13 AMval client = HttpClient(MockEngine) {
engine {
addHandler { request ->
val body = request.body
val req = body.toByteArray().decodeToString()
println(req)
respond("Testing", headers = responseHeaders)
}
}
}
val res = client.get<String>("/")
expect(res).toBe("test")
throws
io.ktor.utils.io.ByteChannelCtorKt.ByteReadChannel([B)Lio/ktor/utils/io/ByteReadChannel;
java.lang.NoSuchMethodError: io.ktor.utils.io.ByteChannelCtorKt.ByteReadChannel([B)Lio/ktor/utils/io/ByteReadChannel;
at io.ktor.client.engine.mock.MockUtilsKt.respond(MockUtils.kt:74)
at io.ktor.client.engine.mock.MockUtilsKt.respond$default(MockUtils.kt:72)
at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invokeSuspend(CreateEndpointTest.kt:35)
at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invoke(CreateEndpointTest.kt)
at CreateEndpointTest$should_have_a_valid_path$1$client$1$1$1.invoke(CreateEndpointTest.kt)
at io.ktor.client.engine.mock.MockEngine.execute(MockEngine.kt:61)
When executed on JVM
And throws
e: java.lang.IllegalStateException: Deserializer for declaration public <http://io.ktor.utils.io/ByteReadChannel%7C8179199761482737139[0]|io.ktor.utils.io/ByteReadChannel|8179199761482737139[0]> is not found
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.handleNoModuleDeserializerFound(KotlinIrLinker.kt:471)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.findModuleDeserializer(KotlinIrLinker.kt:359)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeIrSymbolData(KotlinIrLinker.kt:388)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeIrSymbol(KotlinIrLinker.kt:404)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeIrSymbolAndRemap(IrFileDeserializer.kt:144)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeCall(IrFileDeserializer.kt:387)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeOperation(IrFileDeserializer.kt:897)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeExpression(IrFileDeserializer.kt:938)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeMemberAccessCommon(IrFileDeserializer.kt:345)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeCall(IrFileDeserializer.kt:404)
When executed on jsBrowser
Am I missing a dependency?Ivan
02/05/2021, 11:21 AMIvan
02/05/2021, 11:21 AMwaltermcq
02/17/2021, 10:00 PM