Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

拉取信息出现HTTP/1.1 header parser received no bytes异常 #59

Open
JingQingQwQ opened this issue Sep 28, 2024 · 9 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@JingQingQwQ
Copy link

使用的语言 / Language used

Java

使用的构建工具 / Build tool

Gradle

内容描述 / Description

用的是springboot的方式集成的simbot,下面是报错和依赖信息

2024-09-28T19:29:07.993+08:00 ERROR 23808 --- [stream_unblock] [atcher-worker-8] l.f.simbot.telegram.stdlib.bot.event : Handle an error on long polling task: HTTP/1.1 header parser received no bytes

java.io.IOException: HTTP/1.1 header parser received no bytes
at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Utils.java:348) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Http1Response.java:675) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Http1AsyncReceiver.java:302) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Http1AsyncReceiver.java:268) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:157) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:305) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:274) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.onReadError(Http1AsyncReceiver.java:511) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:596) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onComplete(SSLTube.java:276) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.complete(SSLTube.java:440) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onComplete(SSLTube.java:541) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.checkCompletion(SubscriberWrapper.java:472) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:334) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:259) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:232) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:513) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:268) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149) ~[java.net.http:na]
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230) ~[java.net.http:na]
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702) ~[kotlinx-coroutines-core-jvm-1.8.1.jar:na]
Caused by: java.io.EOFException: EOF reached while reading
... 24 common frames omitted

Exception in thread "DefaultDispatcher-worker-8" java.io.IOException: HTTP/1.1 header parser received no bytes
at java.net.http/jdk.internal.net.http.common.Utils.wrapWithExtraDetail(Utils.java:348)
at java.net.http/jdk.internal.net.http.Http1Response$HeadersReader.onReadError(Http1Response.java:675)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.checkForErrors(Http1AsyncReceiver.java:302)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.flush(Http1AsyncReceiver.java:268)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)
at java.net.http/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:157)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:305)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:274)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver.onReadError(Http1AsyncReceiver.java:511)
at java.net.http/jdk.internal.net.http.Http1AsyncReceiver$Http1TubeSubscriber.onComplete(Http1AsyncReceiver.java:596)
at java.net.http/jdk.internal.net.http.common.SSLTube$DelegateWrapper.onComplete(SSLTube.java:276)
at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.complete(SSLTube.java:440)
at java.net.http/jdk.internal.net.http.common.SSLTube$SSLSubscriberWrapper.onComplete(SSLTube.java:541)
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.checkCompletion(SubscriberWrapper.java:472)
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run1(SubscriberWrapper.java:334)
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper$DownstreamPusher.run(SubscriberWrapper.java:259)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:303)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:256)
at java.net.http/jdk.internal.net.http.common.SubscriberWrapper.outgoing(SubscriberWrapper.java:232)
at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader.processData(SSLFlowDelegate.java:513)
at java.net.http/jdk.internal.net.http.common.SSLFlowDelegate$Reader$ReaderDownstreamPusher.run(SSLFlowDelegate.java:268)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$LockingRestartableTask.run(SequentialScheduler.java:205)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:149)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:230)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:811)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:715)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:702)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@29ab1a21, Dispatchers.Default]
Caused by: java.io.EOFException: EOF reached while reading
... 24 more

bot配置文件:
{ "component": "simbot.telegram", "ticket": { "token": "botxxxxxxx" }, "config": { "server": null, "proxy": null, "longPolling": { "limit": 100 } } }

build.gradle.kts
`
plugins {
id("org.springframework.boot") version "3.3.0"
id("io.spring.dependency-management") version "1.1.5"
id("org.graalvm.buildtools.native") version "0.10.2"
id("io.freefair.lombok") version "8.1.0"
kotlin("jvm") version "2.0.0"
kotlin("plugin.spring") version "2.0.0"
kotlin("plugin.lombok") version "2.0.0"
}

group = ""
version = "1.0-SNAPSHOT"

sourceSets {
main {
java {
srcDir("src/main/kotlin")
}
kotlin {
srcDir("src/main/kotlin")
}
}
}

repositories {
mavenCentral()
}

dependencies {

// simbot-core
implementation("love.forte.simbot:simbot-core-spring-boot-starter:4.6.0")
// telegram-core
implementation("love.forte.simbot.component:simbot-component-telegram-core:0.0.11")

// implementation("io.ktor:ktor-client-okhttp:2.3.12")
runtimeOnly("io.ktor:ktor-client-java:2.3.12")

// mybatis-plus
implementation("com.baomidou:mybatis-plus-spring-boot3-starter:3.5.6")
// mysql
implementation("mysql:mysql-connector-java:8.0.33")
// druid
implementation("com.alibaba:druid-spring-boot-3-starter:1.2.23")
// lombok
implementation("org.projectlombok:lombok:1.18.34")
annotationProcessor("org.projectlombok:lombok:1.18.34")
// gson
implementation("com.google.code.gson:gson:2.11.0")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.boot:spring-boot-starter-aop:3.3.0")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.springframework.boot:spring-boot-starter-data-redis")
implementation("org.apache.commons:commons-pool2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

}

tasks.test {
useJUnitPlatform()
}

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

kotlinLombok {
lombokConfigurationFile(file("lombok.config"))
}

tasks.withType {
systemProperty("file.encoding", "utf-8")
}

tasks.withType {
useJUnitPlatform()
}

`

@ForteScarlet
Copy link
Member

有没有尝试将 ktor-client 的实现切换为其他的试一下,有何效果?例如 ktor-client-ohttpktor-client-cio

@JingQingQwQ
Copy link
Author

都试过,没有效果,发现都是不会重连

@ForteScarlet
Copy link
Member

目前来看是出现了在此处遇到了预期之外的异常而导致的,也许后续会增加配置来决定如何处置未知异常。

异常出现时机是什么?启动即出现、在接近配置的 longPolling.timeout (未配置默认是30分钟)超时时间时出现、还是一段时间未接收到事件时出现?

@ForteScarlet ForteScarlet added bug Something isn't working and removed bug? labels Sep 28, 2024
@ForteScarlet
Copy link
Member

ForteScarlet commented Sep 28, 2024

还有一点就是确定是可以在不配置 proxy 的情况下访问到 telegram 的服务器是吗,Java程序并不能够自动使用在电脑上开启的代理,如果你在使用vpn等工具,可以尝试配置 proxy

简单示例:

{
    "component": "simbot.telegram",
    "ticket": {
      "token": "bot123456789:aaaabbbbcccc"
    },
    "config": {
        "server": null,
        "proxy": { "type": "http", "url": "http://127.0.0.1:7790"  },
        "longPolling": {
            "limit": 100
        }
    }
}

@JingQingQwQ
Copy link
Author

对,我在路由上做了分流

@ForteScarlet
Copy link
Member

对,我在路由上做了分流

了解

异常出现时机是什么?启动即出现、在接近配置的 longPolling.timeout (未配置默认是30分钟)超时时间时出现、还是一段时间未接收到事件时出现?

这方面有什么定位吗

@JingQingQwQ
Copy link
Author

异常暂时没有,我看到他异常后就没有下文了

@ForteScarlet
Copy link
Member

ForteScarlet commented Sep 29, 2024

可尝试一下快照版本 v0.0.12-SNAPSHOT,它在 #60 中增加了 longPolling 的可用配置
longPolling.retrylongPolling.handleRetry, 其中后者 handleRetry 可以调整 strategyALL 使得出现任何(除了 CancellationException 以外)异常都会忽略并继续重新拉取。(默认为 TIMEOUT_ONLY, 本质上大概与之前版本一致)

{
"config": {
  "longPolling": {
    "handleRetry": {
       "strategy": "ALL"
     }
   }
 }
}

快照仓库的配置可参考文档

配置文件的绝大多数属性的说明也在 文档 里补充了,可以参考。(需要注意的是 handleRetry#60 合并、发版之前只存在于快照 v0.0.12-SNAPSHOT 中)

@JingQingQwQ
Copy link
Author

好我试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants