我在我的 Android 项目中使用 ktor 和 Netty 服务器:
embeddedServer(Netty, 8080) {
install(ContentNegotiation) {
gson {}
}
install(WebSockets)
routing {
get("/") {
call.respond("Hello!")
}
}
}
所以我启动我的应用程序并在浏览器中打开智能手机的 IP 地址:http://192.168.1.xxx:8080
有时效果很好(浏览器显示 Hello!
),有时浏览器会告诉我类似 Unable to connect
的信息。我不确定这个问题的原因是什么。