ktor: Simple code straight from documentation returns ERR_EMPTY_RESPONSE
Using 0.9.3 (current version) I tried the following simple code from the documentation:
fun main(args: Array<String>) {
val s = embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello World!", ContentType.Text.Plain)
}
get("/demo") {
call.respondText("HELLO WORLD!")
}
}
}
s.start(wait = true)
}
When I run this code I see:
238 [main] INFO ktor.application - No ktor.deployment.watch patterns specified, automatic reload is not active
290 [main] INFO ktor.application - Responding at http://0.0.0.0:8080
When I visit http://localhost:8080/ in my browser I get ERR_EMPTY_RESPONSE. Adding a println() at the beginning of the get("/")
block reveals that it doesn’t seem to be executing any of that code at all.
I’m currently using ktor in a separate project which doesn’t suffer from this problem - I’ve got no idea what’s different between one and the other. Would appreciate any ideas.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 19 (5 by maintainers)
http://0.0.0.0:8080
can’t be accessed, 127.0.0.1:8080 canJust FYI - my workaround was to use Jetty instead of Netty.
I had the same problem while using mavenCentral() instead of jcenter().