https://kotlinlang.org logo
Join Slack
Powered by
# ktor
  • 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
    • 4
  • 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 ?
  • d

    dorche

    11/21/2025, 7:32 PM
    Hi everyone, I'm running into a weird issue and I'm wondering if anyone can point in the right direction - we are using Ktor client to talk to a backend built by another team and backend responds with 401 in some cases but I have a feeling it returns a malformed response which results in
    io.ktor.utils.io.ClosedByteChannelException
    on our client. More details in thread
    a
    • 2
    • 7
  • f

    Florian

    11/21/2025, 10:07 PM
    Hi, I'm using the ktor plugin to do OpenAPI specification generation, but the
    operationId
    is empty for every route. Does the plugin not have an option to set the
    operationId
    or what would be the intended way to set it?
    b
    • 2
    • 3
  • c

    CLOVIS

    11/22/2025, 2:35 PM
    With Ktor Sockets, I'm getting
    io.ktor.utils.io.ConcurrentIOException: Concurrent read attempts
    on Native but not on the JVM, running the same code. Are there platform-specific limitations around this? Am I just lucky on the JVM? It is possible to programmatically detect if this is allowed or not on the current platform?
    • 1
    • 1
  • c

    CLOVIS

    11/22/2025, 2:49 PM
    Related to the above: I have one coroutine writing to the socket, and one reading. Is that allowed? The error mentions "concurrent read attempts", but I don't think I have multiple coroutines reading. The reading coroutine uses
    Copy code
    while (currentCoroutineContext().isActive) {
        select {
            // …
    
            async {
    		    readChannel.awaitContent(4 * 4) // standard message header size
    		}.onAwait { isActive ->
                // …
            }
        }
    }
    Maybe that's not the correct way to use a
    ByteReadChannel
    in a
    select
    expression?
    a
    • 2
    • 4
  • n

    Nathan Fallet

    11/23/2025, 6:31 PM
    Hello! I had a question about Status Pages plugin and upcoming Kotlin Rich errors. Will we be able to handle rich errors in a similar way we can do now with exceptions and Status Pages plugin? (See attached screenshot for context, considering that Exceptions will then be replaced by rich errors and be responded with call.respond() for example)
    h
    • 2
    • 2
  • h

    Horatio Thomas

    11/24/2025, 8:26 AM
    Hello, I noticed that if you throw a bad request exception, the error message isn't returned in the response. Is this intentional?
    a
    o
    b
    • 4
    • 14
  • a

    Alina Dolgikh [JB]

    11/26/2025, 9:36 AM
    Hi everyone! The survey is still live, and we’d really appreciate it if you could fill it out and share your feedback so we can continue improving the framework. Thank you!
  • m

    maximilianosorich

    11/26/2025, 12:04 PM
    Hello. I am trying to serve sitemap.xml in the root as https://example.com/sitemap.xml using
    Copy code
    routing {
       staticResources("/", "files")
    }
    When I call directly in the browser it works, but when I do:
    curl -I <http://example.com/sitemap.xml>
    The response is: HTTP/1.1 404 Not Found Content-Length: 853 Content-Type: text/html; charset=UTF-8 I suppose this content is from the Status Pages plugin:
    Copy code
    install(StatusPages) {
       statusFile(HttpStatusCode.NotFound, filePattern = "error#.html")
    }
    I have tried the same with curl in localhost with same results. Is this normal behaviour?
    t
    • 2
    • 2
  • v

    Vivek Modi

    11/27/2025, 8:41 PM
    Hi, is there any course on using Ktor for backend development with token-based authentication? I want to learn how to build a secure backend.
  • f

    Florian

    11/27/2025, 11:13 PM
    Are there recommended approaches to version an Api? Something like
    /api/v1/...
    ,
    /api/v2/...
    , but without lot's of duplicate code?
    a
    • 2
    • 2
  • h

    Hristijan

    11/28/2025, 1:04 AM
    https://youtrack.jetbrains.com/issue/KTOR-9135/buildOpenApi-fails-with-unknown-serializer anyone running in this issue too?
    b
    • 2
    • 2
  • t

    Tobias Grether

    11/28/2025, 10:23 AM
    Has anyone here used the ktor html DSL to build a component library, like you would do with React or Vue? Reusable HTML components, represented by classes or functions. I was trying to do so, but with createHTML() I ended up always returning the html of the component as a string, which forces me to wrap it with unsafe{}. I'm sure theres a better solution to this, maybe someone has an idea?
    b
    r
    a
    • 4
    • 3
  • r

    Rey (Kingg22)

    12/01/2025, 3:38 AM
    Hi everyone! 👋 I’m curious to know if anyone here is using SSE with Kotlin and the Ktor client. If so, I’d love to hear about your experience—how you use it, how often, and which parts you find repetitive in your day-to-day work. I’m also wondering whether you think it would be useful to auto-generate some of that boilerplate code using tools like Ktorgen or Ktorfit. As far as I know, Retrofit doesn’t support SSE, but if you know of a similar library that does, I’d really appreciate the recommendation! The idea is to gather a bit of “real-world usage data” on how much SSE is used with the Ktor client, and whether generating parts of the setup (like URL configuration or callbacks, which seem to be the most automatable pieces) would actually be helpful for developers. Thanks in advance for sharing your experience! 🙌ktor new