MiraiForum

    • 注册
    • 登录
    • 搜索
    • 热门
    • 最新
    • 未解决
    • 标签
    • 群组
    • 友情链接

    使用okhttp3进行http请求,会出现机器人直接掉线的情况

    BUG反馈
    1
    2
    228
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • cwyu
      cwyu 最后由 编辑

      机器人运行中,当我使用okhttp3进行http请求的时候,会出现机器人直接掉线的情况,请问有人知道是什么原因吗?偶尔出现。QQ截图20230320032144.png
      错误信息:2023-03-20 02:46:33 V/Bot.3489291735: Event: BotOfflineEvent.Dropped(bot=Bot(3489291735), cause=HeartbeatFailedException: 3489291735.StatHeartbeat, recoverable=true, cause=PacketTimeoutException(message=3489291735.StatHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms), reconnect=true)
      2023-03-20 02:46:33 W/Bot.3489291735: Connection lost, reconnecting... (HeartbeatFailedException: 3489291735.StatHeartbeat, recoverable=true, cause=PacketTimeoutException(message=3489291735.StatHeartbeat Scheduler: Timeout receiving action response, cause=kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms))
      2023-03-20 02:46:33 W/Bot.3489291735: An exception occurred when processing event. Subscriber scope: '<unnamed>'. Broadcaster scope: 'Bot 3489291735.EventDispatcher'
      java.lang.IllegalStateException: NetworkHandler is already closed.
      at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler$StateClosed.sendPacketImpl(CommonNetworkHandler.kt:389)
      at net.mamoe.mirai.internal.network.handler.CommonNetworkHandler.sendPacketImpl(CommonNetworkHandler.kt:36)
      at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.sendAndExpect(NetworkHandlerSupport.kt:123)
      at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$sendAndExpect$1.invokeSuspend(NetworkHandlerSupport.kt)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
      at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
      at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
      at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:233)
      at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
      Suppressed: kotlinx.coroutines.TimeoutCancellationException: Timed out waiting for 5000 ms
      at kotlinx.coroutines.TimeoutKt.TimeoutCancellationException(Timeout.kt:184)
      at kotlinx.coroutines.TimeoutCoroutine.run(Timeout.kt:154)
      at kotlinx.coroutines.EventLoopImplBase$DelayedRunnableTask.run(EventLoop.common.kt:508)
      at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
      at kotlinx.coroutines.DefaultExecutor.run(DefaultExecutor.kt:108)
      at java.base/java.lang.Thread.run(Unknown Source)
      最后是一句2023-03-20 02:47:03 I/Bot.3489291735: Bot cancelled: Bot closed。
      我看了下我的代码,QQ截图20230320032403.png
      QQ截图20230320032421.png 大概率是到这个地方报错了。但是我也不确定是不是代码的问题,因为大部分时间都正常。我刚学kotlin不是很懂,麻烦大佬们看看。

      1 条回复 最后回复 回复 引用 0
      • cwyu
        cwyu 最后由 编辑

        不知道是不是请求的接口的问题。但是我写了错误抛出,某些时候接口问题确实也抛出了。

        1 条回复 最后回复 回复 引用 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact