Skip to content

Server sent event not working with Kotlin #2376

@khi195

Description

@khi195

Hey, I'm trying to get SSE working with Javalin (6.4.0) and kotlin. this is the code

fun main() {

    var app = Javalin.create().start(7070)

    app.get("/"){
        it.result("hello world from SSE app!")
    }

    app.sse("/sse") { client ->
        client.sendEvent("connected", "Hello, SSE")
        client.onClose { println("Client disconnected") }
        client.close() // close the client
    }


    println("Hello World!")
}
  1. this is not hitting sse part, I breakpointed it and put a log inside the handler
  2. should the SSE not be returning content-type text/event-stream, I am getting back text/plain

Not sure where I am going wrong, any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions