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

    Tak Wai Wang

    10/01/2025, 1:26 PM
    Hi, I am using Ktor config and face the problem with the application when it build by
    gradlew installDist
    . The Ktor application will not be able to read the environment variable from the cloud system. But if we build the Ktor application with
    fatJar
    , then the application can read the env variables.
    Copy code
    ENVIRONMENT = LOCAL
    ENVIRONMENT = ${?APPLICATION_ENV}
    The above example from a HOCON file, if the cloud provide a APPLICATION_ENV, then the Ktor config can not read this property.
    ✅ 1
    a
    • 2
    • 2
  • v

    Venkat

    10/01/2025, 2:35 PM
    I want to do the ping/pong only when there is no active dataflow exist in the WebSocket client connection.. is it possible?
    a
    • 2
    • 1
  • b

    bartek.t

    10/01/2025, 3:13 PM
    Is flyway migration working for you with Ktor 3.3.0?
    a
    h
    • 3
    • 9
  • l

    lc

    10/02/2025, 12:21 PM
    HI, im trying to push environment variable via кtor.plugin
    Copy code
    ktor {
        docker {
            jreVersion.set(JavaVersion.VERSION_21)
            localImageName.set("t-project")
            imageTag.set("latest")
            portMappings.set(listOf(DockerPortMapping(8080, 80)))
    
            environmentVariable("BUILD_NUMBER", "1.0.5")
            environmentVariable("JAVA_OPTS", "-Xms512m -Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:+UseStringDeduplication")
    
            externalRegistry.set(
                DockerImageRegistry.externalRegistry(
                    username = provider { "..." },
                    password = provider { "..." },
                    project = provider { "t-project" },
                    hostname = provider { "..." },
                )
            )
        }
    }
    but no env varriables found in image
    a
    r
    • 3
    • 8
  • e

    Emre

    10/02/2025, 5:17 PM
    Does ktor clear out cookies that can not be deserialized? Suppose there was a schema change.
    a
    • 2
    • 3
  • l

    lc

    10/03/2025, 11:23 AM
    Hi, is it possible to get factory pattern with Ktor DI?
    b
    • 2
    • 6
  • t

    Tak Wai Wang

    10/03/2025, 1:30 PM
    Hi, in Ktor dependency injection, is it possible to override en exiting injection which is register in Application.module()?
    b
    s
    • 3
    • 13
  • t

    Taha

    10/05/2025, 9:39 PM
    how to pass arguments when translating strings with i18n in ktor server? the only way i found to reterive strings is via the
    call.i18n(key)
    and it does not accept arguments.
    a
    • 2
    • 1
  • s

    suresh

    10/06/2025, 6:04 AM
    Hi, does the route specific plugin work inside a typesafe route?
    h
    a
    • 3
    • 10
  • h

    Horatio Thomas

    10/06/2025, 7:27 AM
    just racked my brain and wasted a few hours, because the default json serialization for web sockets and content negotiation uses different default values for encoding defaults. In content negotiation encodedefaults defaults to true and in websockets it defaults to false
    a
    • 2
    • 6
  • r

    rnett

    10/07/2025, 4:24 AM
    Hi folks, is there any way to integrate gRPC with Ktor without using kotlinx.rpc? I'd like to do some proxying and re-routing, ideally using Ktor, so just defining services isn't enough - I need to be able to receive a gRPC request and route it to services (or another gRPC call) myself, using something like
    ServerInterceptor
    . Lacking that, is the source for kotlinx.rpc's gRPC integration available anywhere so I could see how it was done?
    y
    • 2
    • 1
  • p

    phteven

    10/09/2025, 9:59 AM
    How does ktor behave when I use specify multiple modules in the ktor config? Will each module run in its isolated context or do they share the same. Example: I have 2 modules which use Resources plugin. Do i need to configure it only once?
    b
    • 2
    • 1
  • s

    Stephan Schröder

    10/09/2025, 12:53 PM
    Ktor (3.3.0) seems to (still) automatically add an
    Accept: */*
    header to any request I send (that didn't contain an Accept header to start with). According to this old answer to this similar problem I'd have to disable all DefaultTransfermers. But that answer is from 2022. Is there a better solution with Ktor 3? Update: I found a workaround! With an OkHttp engine, i can add an interceptor to modify headers after ktor adds it's bonus headers.
    Copy code
    HttpClient(OkHttp) {
        install(HttpTimeout) {
            requestTimeoutMillis = timeout.inWholeMilliseconds
        }
        engine {
            addInterceptor { chain ->
                val original = chain.request()
                val filtered = original.newBuilder().apply {
                    removeHeader(HttpHeaders.Accept)
                }.build()
                chain.proceed(filtered)
            }
        }
    }
    If you have a better solution, I'm all ears.
    a
    • 2
    • 2
  • l

    Lukasz Kalnik

    10/09/2025, 2:24 PM
    There is Ktor 3.3.1 in Maven Central: https://central.sonatype.com/artifact/io.ktor/ktor-bom But I don't see any 3.3.1 Release in Ktor Github: https://github.com/ktorio/ktor/releases
    a
    • 2
    • 3
  • s

    suyash

    10/10/2025, 1:28 PM
    I have deployed my ktor server on Render using exposed I set up my database and using a json file to parse some fake records
    c
    • 2
    • 7
  • r

    reactormonk

    10/10/2025, 4:11 PM
    I've got the situation that my ktor http client doens't fall back onto ipv4 after the ipv6 connection just times out, is there a specific setting for that?
    a
    • 2
    • 2
  • f

    Fedor Erofeev

    10/11/2025, 9:06 AM
    OpenAPI tags seem to be not working in 3.3.0, is anyone facing this issue? Update: have to specify it as e.g.
    @tag users
    if someone having troubles, seems KLIP has some wrong sample
    h
    a
    b
    • 4
    • 5
  • r

    Robert Jaros

    10/13/2025, 5:27 PM
    When deploying my Ktor app to production (running a fat jar) I have an error about generating swagger supporting file. More in thread.
    a
    • 2
    • 4
  • b

    Bernhard

    10/14/2025, 1:33 PM
    Ktor Client: Is there anything built in that generates an HMAC over the request body and allows you to set the value as a header? I found StatelessHmacNonceManager but at least my understanding is that while it generates an HMAC, it's not generated over the request body
    ✅ 1
    a
    • 2
    • 3
  • b

    Bernhard

    10/16/2025, 11:28 AM
    is Ktor server a good choice when the code should potentially run on something serverless like AWS lambda? I know that at least Spring's overhead is probably too high; main concerns are startup time and not having to deal with reflection/annotations should GraalVM be used
    ✅ 1
    m
    • 2
    • 2
  • c

    Cherrio LLC

    10/16/2025, 12:15 PM
    When working with sockets. Is there a way to reactively know when there's a disconnection without polling? Or I'll have to poll?
    a
    • 2
    • 1
  • b

    Bernhard

    10/16/2025, 12:47 PM
    when using Ktor client, is there a way to intercept a single request when making the call? https://ktor.io/docs/client-http-send.html looks like it'll intercept all calls on that client instance; I need to compute a signature over the request body and set it as a header for a single request
    ✅ 1
    j
    p
    • 3
    • 6
  • a

    Abthul Razeeth

    10/19/2025, 6:53 AM
    Hi, I have a ktor setup with JWT authentication, and i have my own version of RSA algorithm overriding sign and verify. When minify is enabled in android project, RSA algorithm's sign is called, but not the verify. It works fine when minify is disabled. I have added --keep for all the related classes in proguard, but still it doesn't work. When the api is hit, Unauthorized 401 is returned. any idea?
    a
    • 2
    • 3
  • a

    Abthul Razeeth

    10/19/2025, 6:57 AM
    I am using ktor 2.3.0
  • s

    suresh

    10/20/2025, 6:56 AM
    Does Ktor support the new
    webMain
    shared target (https://kotlinlang.org/docs/whatsnew2220.html#shared-source-set-for-js-and-wasmjs-targets)? The Ktor JS client engine is not getting resolved on the webMain sourceset.
    a
    • 2
    • 2
  • r

    Ryuhei Furuta

    10/20/2025, 11:33 AM
    Hi! Thanks for maintaining Ktor 🙌 When building a fat JAR with
    ktor-server-config-yaml
    on the classpath, we observed that YamlConfigLoader gets selected and application.conf is not loaded. (It took several hours to solve this problem...) This looks related to how
    META-INF/services
    files are merged for a fat JAR and how JVM ServiceLoader resolves providers, rather than a Ktor-specific bug. I saw some issues referencing this behavior like • https://youtrack.jetbrains.com/issue/KTOR-6610/Log-which-ConfigLoader-has-been-used-for-loading-the-server-configuration • https://kotlinlang.slack.com/archives/C0A974TJ9/p1736451975122839 As Patrik Csikós says in YouTrack issue comment, I thought it would be beneficial to take these actions below. (A) Improve logging: when multiple ConfigLoaders are discovered, log the list of candidates and the reason one was selected. (B) Document the behavior when including multiple ConfigLoader on the classpath. If this direction makes sense, I'd be happy to open a PR for (A) logging and/or (B) docs. Would appreciate guidance on the preferred approach. Thank you!
    a
    • 2
    • 3
  • 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?
  • 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/
    ?