Jetty Netty和Ktor抛掷码头。io.EOFEException
我正在使用Ktor和Jetty创建一个应用程序。有一条规则,在采取某个操作之前,我需要检查端点是否向上/向下。 为此,我创建了一个根据服务进行检查的函数Jetty Netty和Ktor抛掷码头。io.EOFEException,jetty,kotlin-coroutines,ktor,Jetty,Kotlin Coroutines,Ktor,我正在使用Ktor和Jetty创建一个应用程序。有一条规则,在采取某个操作之前,我需要检查端点是否向上/向下。 为此,我创建了一个根据服务进行检查的函数 suspend fun checkStatus( target: Target, login: String, passwordLogin: String, url: String ) { when (target) { Target.Elasticsearch -> { val client =
suspend fun checkStatus(
target: Target,
login: String,
passwordLogin: String,
url: String
) {
when (target) {
Target.Elasticsearch -> {
val client = HttpClient(Jetty) {
install(Auth) {
basic {
username = login
password = passwordLogin
}
}
}
runCatching {
client.get<String>(url)
}.onFailure {
it.printStackTrace()
throw it
}
}
}
}
因此,在继续某些逻辑之前,我在控制器中使用此函数
fun Route.orchestration() {
route("/test") {
post {
runCatching {
checkElasticStatus(
environmentVariable(ev, "elk.username"),
environmentVariable(ev, "elk.password"),
environmentVariable(ev, "elk.https").toBoolean(),
environmentVariable(ev, "elk.host"),
environmentVariable(ev, "elk.port")
)
/** other codes **/
}
}
}
}
但我总是犯错误:
org.eclipse.jetty.io.EofException位于
org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:283)
位于org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:422)
org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:277)位于
org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:381)
在
org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:259)
在
org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
在
org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:223)
在
org.eclipse.jetty.http2.HTTP2Session.newStream(HTTP2Session.java:543)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$jettyRequest$1.invoke(jettyhtprequest.kt:40)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$jettyRequest$1.invoke(jettyhtprequest.kt)
在io.ktor.client.engine.jetty.UtilsKt.withPromise(utils.kt:14)at
io.ktor.client.engine.jetty.JettyHttpRequestKt.executeRequest(JettyHttpRequest.kt:39)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$1.invokeSuspend(jettyhtprequest.kt)
在
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
在kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)在
kotlinx.coroutines.scheduling.CoroutineScheduler.runsafe(CoroutineScheduler.kt:571)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
原因:java.nio.channels.AsynchronousCloseException位于
java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:501)
在
org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:263)
... 还有18个
org.eclipse.jetty.io.EofException位于
org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:283)
位于org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:422)
org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:277)位于
org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:381)
在
org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:259)
在
org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
在
org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:223)
在
org.eclipse.jetty.http2.HTTP2Session.newStream(HTTP2Session.java:543)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$jettyRequest$1.invoke(jettyhtprequest.kt:40)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$jettyRequest$1.invoke(jettyhtprequest.kt)
在io.ktor.client.engine.jetty.UtilsKt.withPromise(utils.kt:14)at
io.ktor.client.engine.jetty.JettyHttpRequestKt.executeRequest(JettyHttpRequest.kt:39)
在
io.ktor.client.engine.jetty.jettyhtprequestkt$executeRequest$1.invokeSuspend(jettyhtprequest.kt)
在
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
在kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)在
kotlinx.coroutines.scheduling.CoroutineScheduler.runsafe(CoroutineScheduler.kt:571)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
在
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
原因:java.nio.channels.AsynchronousCloseException位于
java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:501)
在
org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:263)
... 还有18个
有人能帮我吗?Jetty引擎只支持HTTP/2协议
org.eclipse.jetty.io.EofException
在我向只能用HTTP/1.1响应的资源发出请求时抛出,例如
但是,该错误具有误导性,并且存在错误跟踪程序。Jetty引擎仅支持HTTP/2协议
org.eclipse.jetty.io.EofException
在我向只能用HTTP/1.1响应的资源发出请求时抛出,例如
然而,这个错误是误导性的,并且有一个关于它的错误跟踪程序
fun Route.orchestration() {
route("/test") {
post {
runCatching {
checkElasticStatus(
environmentVariable(ev, "elk.username"),
environmentVariable(ev, "elk.password"),
environmentVariable(ev, "elk.https").toBoolean(),
environmentVariable(ev, "elk.host"),
environmentVariable(ev, "elk.port")
)
/** other codes **/
}
}
}
}