koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.45k stars 242 forks source link

Bug: discord机器人断线重连后,机器人仍为离线状态 #842

Closed dalamudx closed 1 year ago

dalamudx commented 1 year ago

Describe the bug

连接到代理的网络可能不大稳定,会时常出现断线重连的情况,查koishi日志发现最后应该是重连成功了,但是实际discord上看机器人是离线状态,重启koishi后机器人正常在线,不知道有没有解决办法还是只能换代理?

Steps to reproduce

断线重连后会发生

Expected behavior

断线重连后机器人能够正常在线

Screenshots

koishi日志

2022-11-09 00:39:25 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 00:39:31 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 00:47:19 [W] adapter failed to connect to wss://gateway.discord.gg/, code: 1000, will retry in 5s...
2022-11-09 00:47:34 [W] adapter failed to connect to wss://gateway.discord.gg/, code: 1006, will retry in 5s...
2022-11-09 00:55:20 [W] adapter failed to connect to wss://gateway.discord.gg/, code: 1006, will retry in 5s...
2022-11-09 00:55:26 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 01:19:42 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 01:19:47 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 02:07:34 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 02:07:42 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 03:43:09 [W] adapter failed to connect to wss://gateway.discord.gg/, code: 1006, will retry in 5s...
2022-11-09 03:43:16 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 04:36:00 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 04:36:06 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 06:08:44 [W] adapter failed to connect to wss://gateway.discord.gg/, code: 1006, will retry in 5s...
2022-11-09 06:08:49 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 06:42:21 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 06:42:27 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 09:15:20 [W] adapter Discord WebSocket requesting client reconnect., will retry in 5s...
2022-11-09 09:15:26 [I] adapter connect to server: wss://gateway.discord.gg/

机器人状态离线 image 重启koishi之后机器人为正常在线状态

2022-11-09 13:23:57 [I] app Koishi/4.10.0
2022-11-09 13:23:57 [I] app apply plugin group:entry
2022-11-09 13:23:57 [I] app apply plugin group:basic
2022-11-09 13:23:57 [I] app apply plugin help
2022-11-09 13:23:57 [I] app apply plugin suggest
2022-11-09 13:23:57 [I] app apply plugin locales
2022-11-09 13:23:57 [I] app apply plugin commands
2022-11-09 13:23:57 [I] app apply plugin puppeteer
2022-11-09 13:23:57 [I] app apply plugin group:console
2022-11-09 13:23:57 [I] app apply plugin console
2022-11-09 13:23:57 [I] app apply plugin dataview
2022-11-09 13:23:57 [I] app apply plugin logger
2022-11-09 13:23:57 [I] app apply plugin insight
2022-11-09 13:23:57 [I] app apply plugin market
2022-11-09 13:23:58 [I] app apply plugin sandbox
2022-11-09 13:23:58 [I] app apply plugin status
2022-11-09 13:23:58 [I] app apply plugin group:database
2022-11-09 13:23:58 [I] app apply plugin database-mysql
2022-11-09 13:23:58 [I] app apply plugin group:adapter
2022-11-09 13:23:58 [I] app apply plugin adapter-onebot
2022-11-09 13:23:58 [I] app apply plugin adapter-discord
2022-11-09 13:23:58 [I] app apply plugin gocqhttp
2022-11-09 13:23:58 [I] app apply plugin group:FFXIV
2022-11-09 13:23:58 [I] app apply plugin ffxivnews
2022-11-09 13:23:58 [I] app apply plugin group:Command
2022-11-09 13:23:58 [I] app apply plugin echo
2022-11-09 13:23:58 [I] app apply plugin schedule
2022-11-09 13:23:58 [I] app server listening at http://localhost:5140
2022-11-09 13:23:58 [D] gocqhttp 将使用 device.json 内的设备信息运行Bot.
2022-11-09 13:23:58 [D] gocqhttp 当前版本:v1.0.0-rc3
2022-11-09 13:23:58 [D] gocqhttp 使用协议: iPad
2022-11-09 13:23:58 [D] gocqhttp 开始尝试登录并同步消息...
2022-11-09 13:23:59 [I] adapter connect to server: wss://gateway.discord.gg/
2022-11-09 13:23:59 [D] gocqhttp Protocol -> connect to server: 120.232.18.213:8080
2022-11-09 13:24:00 [W] gocqhttp Protocol -> device lock is disable. http api may fail.
2022-11-09 13:24:01 [D] gocqhttp 登录成功 欢迎使用: koishi-bot
2022-11-09 13:24:01 [D] gocqhttp 开始加载好友列表...
2022-11-09 13:24:01 [D] gocqhttp 开始加载群列表...
2022-11-09 13:24:01 [D] gocqhttp 共加载 2 个好友.
2022-11-09 13:24:02 [D] gocqhttp 共加载 2 个群.
2022-11-09 13:24:02 [D] gocqhttp 资源初始化完成, 开始处理信息.
2022-11-09 13:24:02 [D] gocqhttp アトリは、高性能ですから!
2022-11-09 13:24:02 [D] gocqhttp 正在检查更新.
2022-11-09 13:24:02 [D] gocqhttp CQ WebSocket 服务器已启动: [::]:5700
2022-11-09 13:24:02 [I] adapter connect to server: ws://localhost:5700
2022-11-09 13:24:02 [D] gocqhttp 接受 WebSocket 连接: 127.0.0.1:47470 (/)
2022-11-09 13:24:03 [D] gocqhttp 收到服务器地址更新通知, 将在下一次重连时应用.
2022-11-09 13:24:03 [D] gocqhttp 检查更新完成. 当前已运行最新版本.
2022-11-09 13:24:03 [D] gocqhttp 开始诊断网络情况
2022-11-09 13:24:06 [D] gocqhttp 网络诊断完成. 未发现问题

image

Versions

Additional context

No response

shigma commented 1 year ago

这个问题我也遇到过,感觉是网络波动问题。

dalamudx commented 1 year ago

这个问题我也遇到过,感觉是网络波动问题。

那我写个守护进程处理下,遇到掉线先重启下koishi,观察一段时间,要是实在影响使用,不行只能换代理了😣

shigma commented 1 year ago

好的。这个问题之前还专门修过一次,不过看起来没完全解决 :rofl:。后面我也会继续跟踪它。

MirrorCY commented 1 year ago

追一下,这个问题复现在使用 socks5 代理的情况下,将 koishi 直接放在美国服务器后稳定运行了一个月。

MirrorCY commented 1 year ago

再次,discord 适配器复现了重连失败的问题,koishi 端显示在线但不响应任何消息。discord 端显示机器人离线。沙盒内正常 discord: 3.4.2 koishi: 4.11.2 网络环境: aws 美国,未配置代理

MirrorCY commented 1 year ago

重启 koishi 后可以正常使用数小时。 与此同时,telegram 适配器数月全程未出现不响应消息,基本排除网络问题。

MirrorCY commented 1 year ago

🚀