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

    krzysztof

    12/01/2025, 9:53 PM
    Question regarding Ktor’s DI container - is there a way to scope the dependencies or are they singletons by default only?
    b
    • 2
    • 6
  • r

    reactormonk

    12/02/2025, 10:57 AM
    Does the android client support happy eyeballs?
    h
    • 2
    • 3
  • t

    Tak Wai Wang

    12/03/2025, 11:58 AM
    can CIO support Http 2.0 under Ktor?
    k
    a
    • 3
    • 2
  • j

    Julius Babies

    12/03/2025, 4:29 PM
    Is there any chance I can write into a stream on a regular HTTP Request? Like a WebSocket, but without the WebSocket-Layer, just the raw Stream. The Docker Engine gives a
    Upgrade: tcp
    header when starting an exec-Instance without detaching and I want to be. able to write into that stream as stdin. Is it possible to get the ByteWriteChannel of the connection in the .execute { ... }-Block? If not, I could imagine this channel being exposed as a function that requires you to OptIn.
    Copy code
    client.socket.preparePost("/exec/$execId/start") {
        contentType(ContentType.Application.Json)
        setBody(StartExecInstanceResponse(detach = false))
    }.execute { response ->
        response.rawInput // would return the ByteWriteChannel for this request
    }
    a
    • 2
    • 3
  • m

    MrPowerGamerBR

    12/04/2025, 1:38 AM
    Another issue that I found with the Ktor Client Java engine, it seems that you are unable to override the
    Host
    header with the Java engine (while it does work with the CIO engine) https://youtrack.jetbrains.com/issue/KTOR-9158/Cannot-override-the-Host-header-with-the-Java-client-engine
    a
    • 2
    • 1
  • t

    Tak Wai Wang

    12/04/2025, 10:18 AM
    hi, we have got error with apache5 as httpClient and use it as Ktor DI. So when the server restart, we will get this error.
    Copy code
    java.nio.channels.CancelledKeyException: null at java.base/sun.nio.ch.SelectionKeyImpl.ensureValid(Unknown Source) at java.base/sun.nio.ch.SelectionKeyImpl.interestOps(Unknown Source) at org.apache.hc.core5.reactor.IOSessionImpl.setEvent(IOSessionImpl.java:172) at org.apache.hc.core5.reactor.IOSessionImpl.enqueue(IOSessionImpl.java:115) at org.apache.hc.core5.reactor.ssl.SSLIOSession.enqueue(SSLIOSession.java:775) at org.apache.hc.core5.reactor.InternalDataChannel.enqueue(InternalDataChannel.java:286) at org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder.lambda$build$2(HttpAsyncClientBuilder.java:1077) at org.apache.hc.core5.reactor.SingleCoreIOReactor.initiateSessionShutdown(SingleCoreIOReactor.java:155) at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:115) at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:92) at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) at java.base/java.lang.Thread.run(Unknown Source)
    is it anyway to close the apache5 with Ktor DI?
    a
    • 2
    • 9
  • n

    Nathan Fallet

    12/04/2025, 6:10 PM
    Would love to contribute! Any ktor maintainer to let me know if I should start working on it? This is a missing feature that would be used by a lot of backends (configurable with 2/3 lines of codes instead of implementing a custom solution) https://youtrack.jetbrains.com/issue/KTOR-9162/Ktor-server-auth-api-key-plugin
    e
    • 2
    • 2
  • h

    Hristijan

    12/08/2025, 4:55 PM
    hey everyone, is there something like the newly shipped feature in IntelliJ idea that has support for Spring versioning but for Ktor, or an easy/elegant way to handle this in Ktor?
    b
    • 2
    • 1
  • c

    Christopher Mederos

    12/10/2025, 2:12 AM
    using ktor server - what's the recommended way to make concurrent requests to 3rd party services over http?
    Copy code
    routing {
        get("/data") {
            val combinedData = coroutineScope { 
                val dataOneDeferred = async { clientOne.get("data") }
                val dataTwoDeferred = async { clientTwo.get("data") }
            
                return@coroutineScope dataOneDeferred.await() + dataTwoDeferred.await()
            }
            call.respond(combinedData)
        }
    }
    b
    s
    • 3
    • 3
  • l

    Leo N

    12/10/2025, 9:24 AM
    OTEL tracing issue with Ktor 3 Hey guys, We just upgraded our service from Ktor 2.X.X to Ktor 3.2.3 During testing, we suddenly lost some metrics, specifically: new version loose
    http.route
    tag and our Grafana dashboards started to go crazy. Anybody else notice some different behavior in metrics when moving to Ktor 3?
    h
    • 2
    • 1
  • d

    Dmytro Koval

    12/10/2025, 11:38 AM
    It wasn’t the correct channel after all
  • s

    Steyn Geldenhuys

    12/12/2025, 12:53 PM
    Hi everyone! We're using WebRTC with Ktor and have noticed some inconsistency when it comes to the IceServer urls specification. The IceServer data class calls the parameter
    urls
    but it only takes in a singular string. Also the comment above it references MDN that specifies this parameter as "single string or an array of strings". We've been making multiple IceServer objects per URL that we are passing in, but shouldn't this then rather be a list of URLs instead? We're also wondering if there may be an advantage from a browser optimization point of view when passing in a list of URLs for one IceServer. Here's the line in question: https://github.com/ktorio/ktor/blob/6b3bad4b947d0a07c3a9887d2558c9400c3c49ac/ktor-[…]t/ktor-client-webrtc/common/src/io/ktor/client/webrtc/WebRtc.kt
    o
    • 2
    • 6
  • b

    brabo-hi

    12/12/2025, 7:44 PM
    hello guys when using ktor OpenAPI Gradle extension, it does look the request and response body don't support enum type if present, how to go around it
    e
    a
    • 3
    • 2
  • v

    Vivek Modi

    12/15/2025, 2:01 PM
    Hi everyone 👋 I’m setting up dev and prod environment configuration in a Ktor application. Is there any recommended article/blog that explains the best practice for handling dev vs prod? Thanks!
    o
    e
    • 3
    • 8
  • s

    Stylianos Gakis

    12/15/2025, 4:09 PM
    I wanted to do basically what this issue mentions here https://youtrack.jetbrains.com/issue/KTOR-8775/Make-Default-Request-builder-suspend, which is to call a suspending function during each request to append a header. I noticed that HttpSend plugin exists https://ktor.io/docs/client-http-send.html which feels like it should work fine for this. I am doing smth like this, is this a fair workaround until something else exists to achieve this?
    Copy code
    HttpClient().config
      defaultRequest {
        header(... add non-suspend headers here)
      }
      install(HttpSend)
    }.apply {
      plugin(HttpSend).intercept { request ->
        execute(request.apply { header(... add suspend headers here) })
      }
    }
    a
    • 2
    • 1