https://kotlinlang.org logo
Join Slack
Powered by
# server
  • m

    Mohammad Zaki

    06/13/2025, 1:09 PM
    Hi Team , I just migrated to ktor 3.1.3 from 2.3.12 but not sure why call.receive is not working like its not converting my json into data class . This is the extension function i was using earlier but now its not working .
    Copy code
    suspend inline fun <reified T : Any> PipelineContext<*, ApplicationCall>.getBodyContent(): T {
        return call.receive()
    }
    i cant access it inside post block. Can anyone help
    h
    v
    • 3
    • 6
  • m

    Mohammad Zaki

    06/13/2025, 1:32 PM
    Does Koin 4.1 supports Ktor Server 3.1.3 ?
    l
    • 2
    • 2
  • y

    Yorgos S.

    06/16/2025, 8:46 AM
    Just released the new version of
    actor4k
    .
    actor4k
    is a small actor system written in kotlin using Coroutines. The actor model is a design paradigm for building concurrent systems where the basic unit of computation, known as an actor, encapsulates its own state and behavior and interacts with others solely through asynchronous message passing. Each actor processes messages sequentially, which simplifies managing state changes and avoids common pitfalls like race conditions and deadlocks that arise with traditional multithreading approaches. This model is particularly useful for highly concurrent, distributed, and fault-tolerant systems. Its scalability and resilience come from the ability to isolate errors within individual actors through supervision strategies, making it a fitting choice for applications such as real-time data processing, microservices architectures, and any system that requires robust fault isolation and maintainability. Check it out here: https://github.com/smyrgeorge/actor4k
    👍 5
  • k

    Kanon

    06/17/2025, 10:21 PM
    Hi, everyone 👋 I released a generic Value Object library inspired by Zod for Kotlin 🙌 This is no dependence 3rd party libraries. please give me feedback and GitHub Star 💫😭 https://github.com/ysknsid25/iolite
    👏 1
    m
    • 2
    • 3
  • n

    Nicolas

    06/18/2025, 12:16 PM
    Hello Teams 😄 and Thank you for accepting me 😄 I am doing my server with ktor and I used webSocket to do a chat, I hope my question will not be dumb because I am iOS developer at firt 😄 I have the following code to set up my WebSocket with ktor. My problem is the following: if I turn off the internet on the mobile side (iOS) after setup a connection with the socket for about 3 minutes, my socket is no longer active, probably because the ping/pong fails on front side. However, the finally block on server side is often called a long time ago, so the webSocket is close after 20 minutes. How can I prevent this memory leak? and to be sure that after 3minute offline from the client, the webSocket will be remove from my server please. I Have setup the ping pong like this
    Copy code
    fun Application.configureWebSocket(){
        install(WebSockets) {
            pingPeriod = 15.seconds
            timeout = 15.seconds
            maxFrameSize = kotlin.Long.MAX_VALUE
            masking = false
    
        }
    }
    Copy code
    routing {
        webSocket("ws") {
            val token = call.request.queryParameters["token"]
            if (token == null) {
                close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "No Token"))
                return@webSocket
            }
    
            val decodedJWT = try { JwtFactory.buildverifier().verify(token) }
            catch (e: Exception) {
                close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid Token: ${e.message}"))
                return@webSocket
            }
    
            val userId: UUID = try { UUID.fromString(decodedJWT.getClaim(JwtClaimConstant.claimUserId).asString())  }
            catch (e: Exception) {
                close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid Token: ${e.message}"))
                return@webSocket
            }
    
            val sessionId = decodedJWT.id?.let {
                runCatching { UUID.fromString(it) }.getOrNull()
            } ?: run {
                close(CloseReason(CloseReason.Codes.VIOLATED_POLICY, "Invalid or missing sessionId (jti)"))
                return@webSocket
            }
            <http://logger.info|logger.info>("$userId is connected")
    
            try {
                println("$userId start")
                incoming.consumeEach {
                    when (it) {
    
                        is Frame.Text -> {
                            val text = it.readText()
                            println("tototot $userId Received: $text")
                        }
                        is Frame.Close -> {
                            println("tototot $userId WebSocket closed by server with reason: ${it.readReason()}")
                        }
                        is Frame.Ping -> {
                            println("tototot $userId ping: $it")
                        }
                        is Frame.Pong -> {
                            println("tototot $userId pong: $it")
                        }  else -> {
                            println("tototot $userId else: $it")
                        }
                    }
    
    
                }
            } catch (e: Exception) {
                println("$userId error $e")
             } finally {
                println("$userId finally remove")
            }
    
            println("$userId end")
        }
    }
    and I found something weird If I open a websocket on my iOS phone, turnoff the internet (and close my phone) I keep logging this on KTOR: io.ktor.websocket.WebSocket - WebSocket Pinger: received valid pong frame Frame PONG For me if I close my phone the webscket should try a ping and should not receive a pong and close, For me the goal of ping pong is to avoid all this. I am not sure if I have doing everything good 🙂 I am hosting my server on Render Thank you in advance for your time
  • d

    dave

    06/18/2025, 12:27 PM
    👋 Hey everyone - happy Wednesday! We've got some news about what we've been cooking up over at http4k towers... https://http4k.org/news/ai_without_tests_is_just_expensive_random_number_generation/
    http4k 1
    kodee happy 1
    e
    • 2
    • 3
  • n

    Nicolas

    06/23/2025, 9:27 AM
    hello 😄 any idea 😢 ? because I don't know if it's an issue or me who don't know how to use websocket :"(
    h
    • 2
    • 2
  • a

    Asadullah Nadeem

    06/24/2025, 8:43 AM
    Hello
    👋 5
    kodee welcoming 6
  • b

    Bharat Kumar

    06/26/2025, 10:26 AM
    Hi guys how do you do authentication for ktor server backend do you use any libs or manually do it with ktor auth. Also what is the best way if I want to have oauths and normal email password auths too ?
    d
    s
    +2
    • 5
    • 4
  • a

    Alina Dolgikh [JB]

    06/27/2025, 12:13 PM
    Hi everyone! 📹 We’re hosting a livestream together with Azul, where Simon Vergauwen (JetBrains Developer Advocate) and Jiří Holuša (Azul Director of Product Management) will show you how to get the most out of the JVM with Kotlin and Azul Runtime. 💬 We’ll be chatting during the livestream, so feel free to ask your questions! Save the date and register for a reminder: 📆 July 16 🕓 4:00 PM UTC https://info.jetbrains.com/kotlin-livestream-july16-2025.html
    👀 2
  • b

    bk9735732777

    07/03/2025, 6:36 AM
    Hi guys i am having trouble with deploying my ktor backend to render via Docker Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf I am getting this error.
    Copy code
    # Stage 1: Cache Gradle dependencies
    FROM gradle:latest AS cache
    RUN mkdir -p /home/gradle/cache_home
    ENV GRADLE_USER_HOME=/home/gradle/cache_home
    COPY build.gradle.* gradle.properties /home/gradle/app/
    COPY gradle /home/gradle/app/gradle
    WORKDIR /home/gradle/app
    RUN gradle clean build -i --stacktrace
    
    # Stage 2: Build Application
    FROM gradle:latest AS build
    COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle
    COPY --chown=gradle:gradle . /home/gradle/src
    WORKDIR /home/gradle/src
    # Build the fat JAR, Gradle also supports shadow
    # and boot JAR by default.
    RUN gradle buildFatJar --no-daemon
    
    # Stage 3: Create the Runtime Image
    FROM amazoncorretto:22 AS runtime
    EXPOSE 8080
    RUN mkdir /app
    COPY --from=build /home/gradle/src/build/libs/*.jar /app/ktor-docker-sample.jar
    ENTRYPOINT ["java","-jar","/app/ktor-docker-sample.jar"]
    This is my docker file Thread in Slack Conversation
    g
    • 2
    • 4
  • o

    Ohiorenua Aigboje

    07/08/2025, 12:47 PM
    I made a tutorial on how to create an MCP server with kotlin. Will I be breaking the rules if I post the youtube link here
    j
    p
    • 3
    • 5
  • o

    Ohiorenua Aigboje

    07/14/2025, 6:39 AM
    Can someone explain it to me. I don't get the connection of compose wasm to CMP. Compose wasm is to build the UI framework for web, but does it have a backend logic. If I create a project that uses, Android, Ios, WASM, and the app size is 50MB will the wasm also be 50mb. most of those code should go to the backend, right? how does wasm know and communicate with the backend( the logic of the code)
    b
    • 2
    • 5
  • j

    Jens Alfke

    07/19/2025, 6:31 PM
    Is multiplatform Ktor really a practical technology yet? I’ve gotten the basics working and have a basic HTTP server with HTML DSL; then this morning I tried to set up static routes to serve my static content … only to find that this functionality, and the entire io.ktor.server.http.content module, is JVM-only for some reason. (And the web page does not call this out, so I only found out when I tried to use the API in my code.) Serving static files is rock-bottom basic functionality for any web server I’ve ever used. If it’s not multiplatform in Ktor, what else isn’t? This has me doubting my decision to use Kotlin for this project (which cannot depend on the JVM.)
    e
    d
    +2
    • 5
    • 15
  • j

    joseph_ivie

    07/23/2025, 2:54 PM
    We built a server framework (https://github.com/lightningkite/lightning-server) that's been working out really well for us in production. However, I think adoption by others would be hampered by a few issues. One of the advantages of the framework is that it abstracts the common services servers depend on (database, cache, email, SMS, file systems) in a way that makes it really easy to both run your server locally for testing and deploy it to traditionally difficult targets (such as AWS Lambda / API Gateway). It also generates deployment terraform for you based on your server definition. If I broke out these service abstractions into a different library for use with Ktor and other libraries (like http4k), would anyone be interested?
    • 1
    • 1
  • j

    Joel Denke

    08/04/2025, 3:13 PM
    Is it easy to launch your own Kotlin Ktor server from scratch act as proxy to Firebase Admin SDK, easy as in can do with AI agent or generate most of the boilerplate? It doesnt have to be perfect, but good enough to test if its worth it. Just deploy directly to GCP or something. Or something equivalent of that. Can be Apollo GraphQL or whatever.
    ✅ 1
    m
    s
    • 3
    • 194
  • m

    MattF

    08/05/2025, 12:29 PM
    what inspections or compiler options can one enable to avoid something like this happening where the aa & bb line is silently discarded due to a second '&&' missing at the end... val matched = list.find { aa && bb // accidentally deleted a second && at the end of line somehow cc } this doesn't show any error or warning or even any hints in the IDE, it's a bug that really thrown me and I do worry about this happening again although I understand whats happening its a concerning silent discard .
    e
    k
    • 3
    • 3
  • m

    Mohammad Zaki

    08/05/2025, 6:45 PM
    Hi Team , I have a Kotlin Notebook code cell. I have this api. i want to set a timeout here, the default is 10s. I don't want that.
    Copy code
    val response = http.get("<http://127.0.0.1:8080/v1/flashcards?topic=Something&type=quiz&difficulty=hard>")
    response.bodyAsText()
    Can anyone help?
    k
    • 2
    • 1
  • j

    Joel Denke

    08/07/2025, 5:20 AM
    I finally managed to deploy container and run on Google Cloud, but all containers run default private and require OAuth tokens. Whats the recommended approach when integrate that server into a client frontend later on, to protect that token. It has to embed some kind of long lived token somewhere. Maybe possible to use Firebase Auth or something?
  • j

    JonasBecker

    08/14/2025, 10:03 AM
    💼 Full-Stack | Python | AI | Web | Bots | Blockchain Developer 🧠 Open for new projects – freelance, contract, or collaborations! Hi everyone! I'm an experienced full-stack developer with a strong background in: 🚀 Core Stack: Languages: Python, JavaScript/TypeScript Frameworks: FastAPI, Flask, Django, React, Next.js, Vue/Nuxt AI/ML: Custom models, NLP, computer vision, OpenAI integration Bots: Telegram, Discord, automation bots, betting bots, advanced web scraping Blockchain: EVM-based chains (Ethereum, BSC, Polygon), MEV bots, arbitrage, smart contracts (Solidity) Databases: PostgreSQL, MySQL, MongoDB DevOps: Docker, GitHub Actions, CI/CD, AWS, DigitalOcean 💡 What I bring to the table: Clean, scalable architecture and production-grade code Strong problem-solving with focus on automation and performance Clear communication, fast iterations, and deep understanding of business goals Proven experience delivering real-world platforms, tools, and bots 🔍 Available for: Startup MVPs and SaaS builds Custom bots (Telegram, blockchain, automation, data scraping) AI-powered apps and backend APIs Long-term technical partnerships 📬 DM me if you're looking for a reliable, skilled developer. Happy to share portfolio, GitHub, or real project references!
    🤡 6
    🚫 26
    k
    • 2
    • 1
  • a

    Aozen

    09/08/2025, 12:02 PM
    hello everyone first day here is this the general channel?
    h
    g
    • 3
    • 2
  • u

    الخبرات العلمية ScienceExperts

    09/30/2025, 6:59 AM
    guys question i have food delivery app backend in Ktor with 512 ram droplet but i face memory issues during building the app .. the old back was in laravel and it’s works fine any recommendations
    j
    j
    • 3
    • 9
  • t

    Tom Molloy

    10/03/2025, 6:27 AM
    Hi folks, Question re: mcp servers. I’m trying to set up a StreamableHttpServer transport on ktor. I’ve noticed that the kotlin mcp sdk has a PR open for this here. The comments in the PR mention it’s not possible to use this with ktor due to limitations in the routing dsl. I checked out the code from the PR and tried to get it working using the suggestion in the description but to no avail. Does anyone know of a workaround for this? Assuming I have the transport from the PR is there a way to get it working with ktor?
    d
    • 2
    • 16
  • r

    Roger Roca (rogydev)

    10/07/2025, 10:04 AM
    Hello, I have a question for server side, application.yaml works exactly as a .env file for websites? It should be a good approach to gitignore it and then setup it manually in each deployment or is better to have all application-dev.yaml, application-prod.yaml and run it server side with specific config?
    k
    a
    • 3
    • 3
  • d

    Dequency Yates

    10/07/2025, 6:10 PM
    I need project
    e
    t
    • 3
    • 4
  • u

    최민규

    10/09/2025, 10:53 AM
    Hi, When will Kotlin v2.4, which contains rich errors, be released?
    m
    a
    +3
    • 6
    • 7
  • m

    Mohammad Zaki

    10/09/2025, 11:40 AM
    hi team Can we send JWT Token in ktor client web sockets request header?
    n
    • 2
    • 1
  • y

    Yorgos S.

    10/16/2025, 5:31 PM
    sqlx4k: A multiplatform, async SQL Toolkit with compile-time query checks for Kotlin. Supports PostgreSQL, MySQL, and SQLite. sqlx4k is not an ORM. Instead, it provides a comprehensive toolkit of primitives and utilities to communicate directly with your database. The focus is on giving you control while catching errors early through compile-time query validation—preventing runtime surprises before they happen. Check it out here: https://github.com/smyrgeorge/sqlx4k
  • p

    Pitam Poudel

    10/18/2025, 4:30 AM
    🚀 Introducing komposeauth — full-stack authentication for Kotlin Multiplatform. Built for developers who want seamless auth across platforms — it brings together: ⚙️ Spring Authorization Server 💡 Shared KMP SDK 💻 CMP Client SDK ✅ Why it’s better than third-party auth services: No vendor lock-in, no recurring costs, and full control over your data, flow, and UI. Ideal for teams who value privacy, flexibility, and open standards. Both client SDKs are on Maven Central, and the server image is available on Docker Hub. It’s open-source — let’s grow it together! Contribute, give feedback, or just try it out 👉 https://github.com/pitampoudel/komposeauth #Kotlin #ComposeMultiplatform #KMP #OpenSource #Authentication #SpringBoot #Ktor #Docker #Maven #SelfHosted
  • a

    Aaron Freeman

    10/28/2025, 5:07 AM
    I've been working on a Kotlin based HTML template engine for a while. I call it KTML. I wanted one where I could just write HTML and easily create reusable components, and had great production performance. I also wanted it to work with KMP. It's at a decent state now for a beta version (with some framework integrations and a Gradle plugin). Here's the repo: https://github.com/ktool-dev/ktml There's also some small example applications. Let me know what you think.
    🔥 3
    👍 3
    r
    b
    a
    • 4
    • 5