Vladimir
03/11/2021, 3:09 PMjava.util.concurrent.CancellationException: LinkedListChannel was cancelled
(full traceback at https://pastebin.com/GU3a8HMD )
Loop looks like this:
try {
for (frame in websocketSession.incoming) {
frame as? Frame.Text ?: continue
val content = frame.readText()
ctx.sessionScope.launch {
handleMessage(ctx, content)
}
}
} catch (e: ClosedReceiveChannelException) {
// socket is closed from client and handled by ktor
} catch (e: Throwable) {
// error occured (abrupt connection termination or other websocket internal error)
logger.error("Unhandled websocket session error: ${e.message}", e)
}
Ktor 1.5.2, coroutines 1.4.2, netty 4.1.54.FinalIvan
03/12/2021, 4:28 PMMrPowerGamerBR
03/13/2021, 2:33 AMLong
is getting rounded when trying to deserialize it within Kotlin/JS, according to this https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/builtin-classes.md it shouldn't happen... but it does?Joost Klitsie
03/14/2021, 3:19 PMGoku
03/15/2021, 7:27 AMClaude Brisson
03/15/2021, 8:18 AMinstall(Sessions) {
cookie<Session>("JSESSIONID", directorySessionStorage(File(".sessions"), cached = true)) {
cookie.extensions["SameSite"] = "lax"
cookie.path = "/"
}
}
Let say the Session class is a general purpose empty class that I just want always created, independent of any authentication mechanism. What else do I need in my application routing for the Set-Cookies header to be generated in each response ?Sami Eljabali
03/15/2021, 9:28 AMribesg
03/15/2021, 12:37 PMhhariri
Abhishek Bansal
03/15/2021, 4:47 PM<http://io.ktor.utils.io|io.ktor.utils.io>.charsets.MalformedInputException: Input length = 1
when I try to receive gzip
encoded response. Any idea how can I enable gzip
decoding in HttpClient
?Ayomide
03/15/2021, 6:53 PMaltavir
03/17/2021, 2:31 PM```17:24:26.967 [DefaultDispatcher-worker-2 @request-handler#28] ERROR ktor.application - Unhandled: GET - /
java.lang.NullPointerException: jarEntry must not be null
at io.ktor.http.content.JarFileContent.<init>(JarFileContent.kt:41)
at io.ktor.http.content.StaticContentResolutionKt.resourceClasspathResource(StaticContentResolution.kt:62)
at io.ktor.http.content.StaticContentResolutionKt.resolveResource(StaticContentResolution.kt:38)
at io.ktor.http.content.StaticContentResolutionKt.resolveResource$default(StaticContentResolution.kt:24)
at io.ktor.http.content.StaticContentKt$resources$1.invokeSuspend(StaticContent.kt:230)
at io.ktor.http.content.StaticContentKt$resources$1.invoke(StaticContent.kt)
at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:246)
at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:116)
at io.ktor.util.pipeline.SuspendFunctionGun.execute(SuspendFunctionGun.kt:136)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
at io.ktor.routing.Routing.executeResult(Routing.kt:155)
at io.ktor.routing.Routing.interceptor(Routing.kt:39)
at io.ktor.routing.Routing$Feature$install$1.invokeSuspend(Routing.kt:107)
at io.ktor.routing.Routing$Feature$install$1.invoke(Routing.kt)
at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:82)
at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:60)
at io.ktor.util.pipeline.DebugPipelineContext.execute(DebugPipelineContext.kt:66)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invokeSuspend(DefaultEnginePipeline.kt:124)
at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$2.invoke(DefaultEnginePipeline.kt)
at io.ktor.util.pipeline.DebugPipelineContext.proceedLoop(DebugPipelineContext.kt:82)
at io.ktor.util.pipeline.DebugPipelineContext.proceed(DebugPipelineContext.kt:60)
at io.ktor.util.pipeline.DebugPipelineContext.execute(DebugPipelineContext.kt:66)
at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:79)
at io.ktor.server.cio.CIOApplicationEngine$handleRequest$2.invokeSuspend(CIOApplicationEngine.kt:189)
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)
The error arises on liberica-15 (CIO) when useing static{resources()}
and everything works fine on graalvm11. Does anybody have the same problem? The issue.Arnau Miro
03/17/2021, 4:37 PMjeggy
03/17/2021, 5:14 PMcurl --request POST --form "field=value" <http://localhost:8080>
I have tried looking at submitForm
but when using this it just gives this error: Serializer for class 'FormDataContent' is not found.
Arnau Miro
03/17/2021, 7:08 PMmichaelv
03/18/2021, 9:22 AMBertram Kirsch
03/19/2021, 4:15 PMunderpants()
and groot()
?
class SomeApp {
fun Application.main(testing: Boolean = false) {
when {
isDev -> {
// For dev environment only
routing {
groot()
underpants()
}
}
isProd -> {
// Do things only in prod
routing {
authenticate {
groot()
underpants()
}
}
}
}
// Do things for all the environments
install(ContentNegotiation) {
gson {
setPrettyPrinting()
}
}
}
}
fun Route.groot(
) {
get("/api/groot") {
val map: HashMap<Int, String> = hashMapOf(1 to "I", 2 to "am", 3 to "groot!")
call.respond(map)
}
}
:
:
Rohde Fischer
03/21/2021, 7:43 PMPartData.FileItem
s 🙂 now the big bad boy, because the `FormItem`s are json that needs to mapped to the DTOs, normally I'd do call.receive<FooDto>()
and then take it from there, but there's no apparent equivalent logic on the FormItem
that I can find. What is the best approach for this, so I don't have to re-implement part/all of the receive logic?Aleksandr Ivanov
03/22/2021, 5:07 AMArchie
03/22/2021, 11:03 AMIosClientEngine
inside my iosMain
but I can't seem to find the builder function Ios
. I've added the dependency:
val iosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:1.5.2")
}
}
But I still couldn't access Ios.create { ... }
? I am able to see internal IosClientEngine(...): ...
) but not the Ios
client. Is there something specific that I should do? please help. Thanks in advance.CLOVIS
03/22/2021, 6:10 PMbasic
and digest
, how can I use the other authentication methods?
https://ktor.io/docs/features-auth.html#providerssushma nayak
03/22/2021, 9:44 PMoverride suspend fun <T : Any> getJsonFromRouter(router: APIRouter, success: Success<T>, failure: Failure) {
try {
val json = httpClient.get<String>(requestFromRouter(router))
Json.decodeFromString(T.serializer(), json)
.entries
.also(success)
} catch (ex: Exception) {
Failure(error = ex)
}
}
I’m getting error on T.serializer()
. Error = “Not enough information to infer type variable T”. On iOS we have Decodable which allows these kind of generic implementation.
Was wondering if this is allowed on kotlin or this can’t be achieved and an actual type in place if generic T is required?Nami
03/22/2021, 11:54 PMkotlinx.serialization
Apparently I can’t respond back the Data while using datetime(“created_at”)
method in exposed!
Any solution?sushma nayak
03/23/2021, 10:30 AMRafał Kuźmiński
03/23/2021, 2:52 PMclient.get<HttpStatement>(downloadUrl).execute {
var offset = 0
val byteBufferSize = 1024 * 100
val channel = it.receive<ByteReadChannel>()
val writeChannel = osmFile.writeChannel()
do {
val data = ByteArray(byteBufferSize)
val currentRead = channel.readAvailable(data, offset, byteBufferSize)
writeChannel.writeAvailable(data,offset,currentRead)
offset += currentRead
println("Pushed $offset bytes with current read $currentRead")
} while (currentRead >= 0)
}
I see that it will download file only until byteBufferSize. I though it was limit for one package, but something in code is making this hard top limit.
I though it would work like this:
1. set bufferSize limit for package
2. open write channel for file
3. create ByteArray to store bytes from one package
4. read from readChannel bytes, using current offset, and bufferSize limit, and write it to ByteArray
5. read from ByteArray and save those bytes into file
Can someone explain me what I did wrong? Thanks!
PS file is downloaded for 100 kb and it stops. If limit wouldn't be so perfect, it would crash with OutOfBounds exceptionHasan Hosgel (alosdev)
03/24/2021, 8:45 AMSatyam Agarwal
03/24/2021, 5:31 PMmaxConnectionsCount
, maxConnectionsPerRoute
, pipelineMaxSize
in http client with CIO engine.
Also what is the role of threadsCount
with coroutines in CIO engine ? The kotlin doc inside :
maxConnectionsCount = Maximum allowed connections count.
maxConnectionsPerRoute = Maximum connections per single route.
pipelineMaxSize = Maximum number of requests per single pipeline.
threadsCount = Network threads count advice.
It is crisp, and I understand it, but I also assume here. I would like a better explanation. Please help 🙂Big Chungus
03/24/2021, 5:43 PM2021-03-24T17:42:21.770240342Z [INFO ] 17:42:21 [tDispatcher-worker-2] Application - 401 Unauthorized: POST - /api/libraries
2021-03-24T17:42:21.981263639Z [INFO ] 17:42:21 [tDispatcher-worker-3] Application - 201 Created: POST - /api/libraries
Has anyone experienced it themselves?Owain Evans
03/25/2021, 1:36 AMApplicationCall
function is called I'm already on a coroutine context.
My questions are:
• Do I need to ever move away from the default context that ktor server call starts on? - I don't think I'm doing anything computationally expensive (I think), but I am wrapping some third party callbacks like firestore and calling a few third party api's which I'm using the ktor client for anyway.
• Are there tools to monitor and discover what parts of the code I should be moving to a different, lower priority, context?Gyu hyeon Lee
03/25/2021, 8:31 AM