https://kotlinlang.org logo
Join Slack
Powered by
# ktor
  • r

    ryanbreaker

    10/21/2025, 4:24 PM
    @Jeff Hudson Heya, I was just wondering why the
    withMdc
    function was removed from Kairo in v6, or was it just moved somewhere else? https://github.com/hudson155/kairo/blob/v5.15.1/kairo-mdc/src/main/kotlin/kairo/mdc/withMdc.kt
    j
    • 2
    • 14
  • s

    Sangeeta

    10/26/2025, 10:28 AM
    Hi Team, I am using the following environment for my project: • Kotlin: 2.2.20 • Ktor: 3.3.1 I am generating OpenAPI specifications using
    ./gradlew buildOpenApi
    . I noticed a couple of things: 1. The
    @description
    annotation in KDoc (as documented here) does not appear in the generated OpenAPI output. It seems the description is ignored, while the first line of the KDoc becomes the summary. 2. The OpenAPI spec currently includes internal endpoints (e.g.,
    /json/kotlinx-serialization
    ). Is there a way/annotation to exclude such endpoints from the generated spec? 3. Is there any support or recommended approach for nested tags? Currently, only flat tag grouping is supported. Thanks in advance for the guidance!
    b
    • 2
    • 8
  • a

    Anders

    10/28/2025, 9:36 AM
    When i run many parallell tests with ktor testApplication i always hit the 10 second timeout on some tests no matter what i configure. I use junit 5, anyone else had this problem?
    a
    • 2
    • 15
  • f

    Florian

    10/30/2025, 7:09 PM
    Hi, I am looking at https://ktor.io/docs/server-request-validation.html and wondering, whether I should install RequestValidation for every route? The Docs just say it can be installed multiple times, but would that be recommended? How should I handle it if I need different validation for e.g.
    GET /users/{id}
    ,
    PUT /users/{id}
    ,
    GET /users/
    ?
    a
    a
    • 3
    • 2
  • h

    Hong Phuc

    11/02/2025, 7:26 AM
    Hi everyone, I'm seeing this weird behaviour with ktor-jetty server where when running the code via the commandline, the program log doesn't include any thread name that belong to the jetty server, here is an example:
    Copy code
    Nov 02 06:53:48 backend-server java[675013]: Routing resolve result:
    Nov 02 06:53:48 backend-server java[675013]:   SUCCESS @ /api/posts/(method:POST)
    Nov 02 06:53:48 backend-server java[675013]: This is session null
    Nov 02 06:53:48 backend-server java[675013]: 2025-11-02 06:53:48.248 [eventLoopGroupProxy-4-2] TRACE i.k.server.engine.DefaultTransform - Transformed class io.ktor.utils.io.ByteChannel to class io.ktor.http.cio.CIOMultipartDataBase for /api/pos>
    Nov 02 06:53:48 backend-server java[675013]: 2025-11-02 06:53:48.249 [eventLoopGroupProxy-4-2] ERROR Application - Unhandled: POST - /api/posts
    Nov 02 06:53:48 backend-server java[675013]: java.lang.NullPointerException: null
    Nov 02 06:53:48 backend-server java[675013]:         at com.yourart.RoutingKt$configureRouting$1$5.invokeSuspend(Routing.kt:155)
    Nov 02 06:53:48 backend-server java[675013]:         at com.yourart.RoutingKt$configureRouting$1$5.invoke(Routing.kt)
    Nov 02 06:53:48 backend-server java[675013]:         at com.yourart.RoutingKt$configureRouting$1$5.invoke(Routing.kt)
    Nov 02 06:53:48 backend-server java[675013]:         at io.ktor.server.routing.RoutingNode$buildPipeline$1$1.invokeSuspend(RoutingNode.kt:126)
    Nov 02 06:53:48 backend-server java[675013]:         at io.ktor.server.routing.RoutingNode$buildPipeline$1$1.invoke(RoutingNode.kt)
    This is when I'm running the code locally via Intellij:
    Copy code
    Routing resolve result:
      SUCCESS @ /api/posts/(method:POST)
    This is session null
    2025-11-02 18:29:27.989 [ktor-jetty-8000-1] TRACE i.k.server.engine.DefaultTransform - Transformed class io.ktor.utils.io.ByteChannel to class io.ktor.http.cio.CIOMultipartDataBase for /api/posts
    2025-11-02 18:29:28.026 [ktor-jetty-8000-3] TRACE a.s.k.r.h.operation.OperationHandler - operation started
    2025-11-02 18:29:28.053 [ktor-jetty-8000-4] DEBUG a.s.k.r.a.c.ProfileCredentialsProvider - Loading credentials from profile `default`
    2025-11-02 18:29:28.062 [ktor-jetty-8000-4] DEBUG a.s.k.r.a.c.ProfileCredentialsProvider - Resolving credentials from static credentials
    Does anyone know why this is the case? Thanks in advance
    a
    • 2
    • 1
  • h

    Hong Phuc

    11/02/2025, 7:42 AM
    Also, I happened to ran into this error as well, does anyone know what the part where it said
    Concurrent read attempts
    mean? I'm trying to read a file in this function where this error happened.
    Copy code
    2025-11-02 07:39:59.407 [eventLoopGroupProxy-4-3] ERROR Application - Unhandled exception caught for CoroutineName(call-handler)
    Nov 02 07:39:59 backend-server java[675297]: io.ktor.utils.io.ConcurrentIOException: Concurrent read attempts
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.utils.io.ByteChannel.awaitContent(ByteChannel.kt:272)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.utils.io.ByteReadChannel$DefaultImpls.awaitContent$default(ByteReadChannel.kt:30)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.utils.io.ByteReadChannelOperationsKt.discard(ByteReadChannelOperations.kt:349)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.utils.io.ByteReadChannelOperationsKt.discard$default(ByteReadChannelOperations.kt:344)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invokeSuspend(DefaultEnginePipeline.kt:42)
    Nov 02 07:39:59 backend-server java[675297]:         at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    Nov 02 07:39:59 backend-server java[675297]:         at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:99)
    Nov 02 07:39:59 backend-server java[675297]:         at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:65)
    Nov 02 07:39:59 backend-server java[675297]:         at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:327)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:149)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:134)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:89)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:109)
    Nov 02 07:39:59 backend-server java[675297]:         at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:86)
    Nov 02 07:39:59 backend-server java[675297]:         at
    a
    • 2
    • 6
  • z

    Zyle Moore

    11/02/2025, 10:41 PM
    How can I configure Ktor to use a custom serializers module during content negotiation, specifically for a polymorphic type? Something simple like
    Copy code
    val serializerModule = SerializersModule {
        polymorphic(Person::class) {
            subclass(SerializablePerson::class)
        }
    }
    r
    • 2
    • 3
  • s

    suresh

    11/04/2025, 12:37 AM
    I am using Ktor 3.3.1 with the
    Jetty engine
    . Calling
    call.request.servletRequestAttributes
    from the call interceptor throws the following error. Any idea why it’s not set for the Jetty engine?
    a
    • 2
    • 9
  • h

    Horatio Thomas

    11/05/2025, 6:49 AM
    Any sample apps using DI yet: https://ktor.io/docs/server-dependency-injection.html?topic=rx?
    a
    • 2
    • 2
  • h

    Horatio Thomas

    11/05/2025, 9:11 AM
    Was checking out the ktor chat project and just realized, you can do this. Pretty cool. Overall the ktor chat project is very elegant. I have some refactoring to do.
  • s

    suresh

    11/06/2025, 2:40 AM
    Is there any way to configure multiple connectors in the HOCON file (including the sslConnector) ?
    a
    • 2
    • 1
  • a

    Alina Dolgikh [JB]

    11/06/2025, 10:05 AM
    📣 The Ktor Annual Survey is live and we’d love your feedback! Whether you’ve built production systems with it or are just experimenting, your input will help us make Ktor better for everyone. Share your experience with its features, documentation, and tools. ktor new* *Take the survey: https://surveys.jetbrains.com/s3/4c0c162c2785
    ktor new 6
  • r

    Ryan Woodcock

    11/06/2025, 7:15 PM
    Hey, i'm getting a strange error with Ktor 3.3.2 and Kotlin 2.2.21 when using the wasmJs HttpClient: ReferenceError: process is not defined at io.ktor.util.logging.getKtorLogLevel This is happening when I try to use the Auth plugin, since it calls the KtorSimpleLogger. When I read the source it says its running catching but apparently I'm still getting the ReferenceError
    a
    • 2
    • 2
  • s

    suresh

    11/07/2025, 12:14 AM
    Hi @Bruce Hamilton Regarding the new OpenAPI spec generation, I’m encountering a few issues:
    b
    • 2
    • 5
  • a

    Arjan van Wieringen

    11/07/2025, 6:56 AM
    Here is a silly question.... can Ktor Server be made into a more generic (server) application runtime? I really like the way Ktor is configurable and extendable and a lot of things aren't necessarily HTTP-server related: config management, application parameters, DI, plugins, App lifecycle events. In that sense the http-server can also be a plugin? Out of the box Ktor has some pretty nice ways of setting up and configuring your app. The reason I was thinking about this is that I was adding a simple kafka consumer in my app using a plugin and the plugin system and DI made that very ergonomic:
    Copy code
    fun Application.module(myService: MyService) {
        subscribe(topic = "my-topic", autoOffsetReset = Latest) {
             on<UserRegistered> { event ->
                myService.userHasRegistered(event.user)
             }
        }
    }
    No need for HTTP (although I use it for liveness and readyness probe) but I use al the Ktor app features
    👍 1
    b
    r
    a
    • 4
    • 6
  • c

    chrisjenx

    11/07/2025, 9:04 PM
    Anyone else noticed that the Ktor plugin in Intellij has been broken for ages?
    j
    • 2
    • 6
  • v

    Vivek Modi

    11/08/2025, 7:47 AM
    Hey does ktor work with grpc? If yes which client does it support?
    b
    • 2
    • 3
  • h

    Hristijan

    11/09/2025, 12:48 PM
    hey guys, i am having some issue with the CORS plugin, this is my code check 🧵 when i curl the url i do not see the allow methods i’ve added
    a
    • 2
    • 13
  • h

    Horatio Thomas

    11/11/2025, 9:05 AM
    Thinking of moving from the android ktor-client to the jvm one to use websockets. Would there be a reason I might want to consider a different one?
    a
    • 2
    • 2
  • a

    Andrej Kovar

    11/11/2025, 10:32 PM
    [Ktor - Android - performances] Hi, we are migrating our REST handling from Retrofit + kotlinx.serizalization JSON to Ktor + kotlinx.serizalization JSON in order to move network layer to KMP and reuse it on iOS. While testing, we noticed significant performance degradation when we executed 10-20 REST calls in parallel (response body size ~2MB each): Ktor + kotlinx.serizalization JSON • Triggering much more Garbage collections with a bunch of following logs in Logcat: ◦ Waiting for a blocking GC Alloc ◦ WaitForGcToComplete blocked Alloc on Background for 868.208ms • Heap spike up to 500MB Retrofit + kotlinx.serizalization JSON • Heap spike up to 250MB • Not triggering GC as mentioned above What could be the reason for this? Is it possible that Ktor + kotlinx.serizalization JSON is creating much more short-lived objects and consumes more memory in order to parse large JSON responses?
    a
    h
    • 3
    • 4
  • h

    Horatio Thomas

    11/12/2025, 7:16 AM
    @Aleksei Tirman [JB] I started to dig thru the ktor-chat sample app and their are a lot of common reusable models where it almost looks like it is building a ktor/multiplatform-framework. Are there any plans for something like this?
    a
    b
    • 3
    • 7
  • h

    Hristijan

    11/12/2025, 9:10 AM
    Is netty still not supported in Graalvm? https://youtrack.jetbrains.com/issue/KTOR-2558
    a
    • 2
    • 1
  • a

    Alexander Zhirkevich

    11/12/2025, 1:27 PM
    Is there a way to set response headers for a websocket route?
    h
    a
    • 3
    • 6
  • m

    Max

    11/13/2025, 8:12 PM
    Wondering if anybody has encountered anything similar - I am serving a KTOR app as a servlet on a liberty app server. It works okay however there is an issue with the routing in that, every couple of requests to the same path it serves a response from a different path. Access log confirm the correct path is received but KTOR logs that it received a different path. This is not present when run standalone and there is no request filtering.
  • m

    MrPowerGamerBR

    11/14/2025, 11:48 PM
    I think I found a bug with Ktor's Java Client + SSE
    Copy code
    suspend fun main() {
        val http = HttpClient(Java) {
            this.expectSuccess = false
            this.followRedirects = false
    
            install(SSE)
        }
    
        val sseSession = http.sseSession("<http://127.0.0.1:13004/sse>") {}
    
        sseSession.cancel()
    
        delay(100_000)
    }
    The SSE session does NOT close on the backend, this bug does not happen when using the CIO engine (will create a proper bug report later)
    a
    • 2
    • 2
  • t

    toneerav

    11/17/2025, 5:04 PM
    Hello all 👋, I am using Ktor Client in Kotlin Multiplatform app. And theres one use case where i need help/suggestion. ktor Version Details • ktor Ktor 3.1.0 Problem • When I try to inspect the response in a response interceptor, reading
    response.body
    (or
    bodyAsText()
    ) consumes it so downstream code can’t receive it anymore. • The usual auth callback flow only triggers on network/HTTP 401 — here the HTTP status is 200 so that doesn’t help. eg.
    refreshToken
    from auth provider Usecase • Server sometimes returns HTTP 200 but the JSON body contains a
    "code"
    field. If
    "code" == 401"
    I need to call the refresh-token API, update the auth token, then replay the original request with the new token. So even in HTTPStatus code 200 I need check response and validate about 401 case. So how to intercept response, call the required api in between based on response and Replay the request. ? can anyone please suggest better approach or any document or link ?
    a
    d
    • 3
    • 3
  • t

    Tak Wai Wang

    11/20/2025, 11:19 AM
    For Ktor test framework, when we using testApplication to start up the Ktor application, it is not possible to combine with io.restassured.RestAssured ( We want to to use RestAssured to verify the swagger.yaml ). Is it some other way we can test it without using E2E solution?
    a
    • 2
    • 2
  • n

    Niclas Kron

    11/20/2025, 1:46 PM
    For legacy reasons I need to talk to API:s that return both success and error body as http 200. How can i parse/approach that with ktor+kotlinx.serialization? If deserialization fails I get a
    JsonConvertException
    and not a
    ResponseException
    with the
    HttpResponse
    that I can parse into a different structure..
    a
    • 2
    • 6
  • h

    Hristijan

    11/20/2025, 3:27 PM
    Hey everyone, does anyone know how to unit test SSE on the client side (Android, iOS), I couldn't find any examples
    a
    • 2
    • 2
  • l

    LG

    11/20/2025, 11:40 PM
    Hi everybody 👋🏼 I'm looking for opensource BE projects that are using Ktor What's your recommandations ?