机器人运行中,当我使用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不是很懂,麻烦大佬们看看。
cwyu 创建的主题
-
0
赞同2
帖子181
浏览 -
2
赞同70
帖子10500
浏览 -
使用GPT-3模型的聊天机器人
插件发布 • • cwyu0
赞同7
帖子2800
浏览 -
1
赞同46
帖子5370
浏览