AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug] 双份日志连接。是不是会导致双倍的消耗?以及为啥出现双份连接

Open zanglikun opened this issue 10 months ago • 3 comments

What happened / 发生了什么

[11:21:15] [Core] [INFO] [routes.config:173]: Saving config, is_core=True [11:21:15] [Core] [INFO] [platform.manager:57]: 载入 aiocqhttp(个人机器人) 平台适配器 ... [11:21:15] [Core] [INFO] [routes.config:173]: Saving config, is_core=True [11:21:15] [Core] [INFO] [platform.manager:57]: 载入 aiocqhttp(个人机器人) 平台适配器 ... [11:21:39] [Core] [INFO] [aiocqhttp.aiocqhttp_platform_adapter:89]: aiocqhttp(OneBot v11) 适配器已连接。 [11:21:39] [Core] [INFO] [aiocqhttp.aiocqhttp_platform_adapter:89]: aiocqhttp(OneBot v11) 适配器已连接。

Reproduce / 如何复现?

开启关闭个人机器人

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

Docker

OS

macOS

Logs / 报错日志

[11:21:15] [Core] [INFO] [routes.config:173]: Saving config, is_core=True [11:21:15] [Core] [INFO] [platform.manager:57]: 载入 aiocqhttp(个人机器人) 平台适配器 ... [11:21:15] [Core] [INFO] [routes.config:173]: Saving config, is_core=True [11:21:15] [Core] [INFO] [platform.manager:57]: 载入 aiocqhttp(个人机器人) 平台适配器 ... [11:21:39] [Core] [INFO] [aiocqhttp.aiocqhttp_platform_adapter:89]: aiocqhttp(OneBot v11) 适配器已连接。 [11:21:39] [Core] [INFO] [aiocqhttp.aiocqhttp_platform_adapter:89]: aiocqhttp(OneBot v11) 适配器已连接。

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [ ] Yes!

Code of Conduct

zanglikun avatar Jan 08 '26 03:01 zanglikun

你遇到的双份日志和双份 aiocqhttp 适配器连接,确实会导致资源消耗翻倍,也可能引发 API 冲突或异常。这通常是因为 aiocqhttp 适配器被初始化了两次,可能是配置多次加载、reload/terminate 没有正确调用,或者关闭时没有彻底清理旧实例导致的。代码层面目前没有防止重复初始化的机制,也没有强制单例或彻底断开连接的保障,所以如果 adapter 没有被完全终止就再次启动,会出现你看到的双份日志和连接现象(详见相关代码分析 和 历史 issue)。

建议你:

  • 检查 config 里是否有重复的 aiocqhttp 配置项。
  • 每次 reload 或关闭个人机器人时,确保 terminate 已经执行并且旧实例被移除。
  • 避免短时间内频繁启停个人机器人,防止 adapter 清理不及时。
  • 如遇到双份连接,可尝试重启容器,确保所有 adapter 实例都被清理。

如果需要彻底解决,建议后续在代码层面加上 adapter 单例检查或更严格的 terminate 逻辑,防止重复加载和连接。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about AstrBot with Dosu Add Dosu to your team

dosubot[bot] avatar Jan 08 '26 03:01 dosubot[bot]

如果你尝试关闭再打开适配器,连接数量会变多吗?

OnlyblackTea avatar Mar 06 '26 11:03 OnlyblackTea

这个问题已经被修复。

Soulter avatar May 01 '26 06:05 Soulter