MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

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

    BUG反馈
    1
    2
    80
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cwyu
      cwyu last edited by

      机器人运行中,当我使用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 Reply Last reply Reply Quote 0
      • cwyu
        cwyu last edited by

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

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact