err_empty_response何时呼叫KTOR服务器方法

发布于 2025-02-06 04:02:50 字数 970 浏览 2 评论 0原文

我已经在Localhost 8081端口上启动了KTOR服务器实例 app.conf

ktor {
    deployment {
        port = 8081
        port = ${?PORT}
    }
    application {
        modules = [ server.AdminModuleKt.adminModule ]
    }
    hikariconfig = "resources/dbconfig.properties"
}
    jwt {
        secret = "secret"
        issuer = "http://0.0.0.0:8081/"
        audience = "http://0.0.0.0:8081/admin/audience"
        realm = "Access to 'audience'"
    }

服务器启动正常,但是当我尝试调用任何方法时,它只响应err_empty_response 方法示例

        get(BASE_PATH.plus(PING_PATH)) {
            call.response.status(HttpStatusCode.OK)
            call.respond("Service available")
        }

它可以正常工作,但是有一天它开始发送空响应。 主要课程 fun main(args:array< string>):unit = io.ktor.server.netty.entty.enginemain.main.main(args)

in build> build.gradle.gradle mainClassName =“ io.ktor.server.netty.enginemain”

I have started ktor server instance on localhost 8081 port
app.conf

ktor {
    deployment {
        port = 8081
        port = ${?PORT}
    }
    application {
        modules = [ server.AdminModuleKt.adminModule ]
    }
    hikariconfig = "resources/dbconfig.properties"
}
    jwt {
        secret = "secret"
        issuer = "http://0.0.0.0:8081/"
        audience = "http://0.0.0.0:8081/admin/audience"
        realm = "Access to 'audience'"
    }

Server starts normal, but when i tries to call any method it respond only ERR_EMPTY_RESPONSE
Method example

        get(BASE_PATH.plus(PING_PATH)) {
            call.response.status(HttpStatusCode.OK)
            call.respond("Service available")
        }

It works fine, but in one moment it start to send empty responses.
Main class
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

In build.gradle
mainClassName = "io.ktor.server.netty.EngineMain"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天冷不及心凉 2025-02-13 04:02:52

问题是依赖关系冲突。
我有Kotlinx序列化版本2+和其他功能1.6.x版本
这就是为什么路由 in 应用程序不适合DSL错误
@[错误:io.ktor.util.pipeline.contextdsl]
使所有功能依赖关系1.6.x解决了问题

The problem was in dependencies conflicts.
I had kotlinx serialization version 2+ and other features version 1.6.x
That is why routing in Application didn't work with DSL error
@[ERROR : io.ktor.util.pipeline.ContextDsl]
Making all feature dependencies 1.6.x has solved the problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文