[Bug] Astrbot + QQ官方机器人组合长时间运行后,用户会单方向和Bot断联

オープン
#11,130 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

The log line "Websocket session starting" comes from qqofficial/qqofficial_platform_adapter.py around line 304, and the manual restart path runs through platform.manager. Start with the adapter's websocket reconnect loop to see why it keeps logging a start without establishing a session after a silent drop. Done means the adapter recovers on its own after the long-running disconnect, which needs a reproduction that takes roughly 30 hours or a mocked long-lived connection.

索引モデルが issue の本文から書いたものです。

説明

bug
问题描述

运行Astrbot加QQ官方机器人,大概30个小时左右用户会单方向和Bot断联,此时用户向bot发消息会提示“机器人的灵魂不在线”,但Bot的主动消息类插件仍然能向用户发送消息,此时日志里反复出现[QQOfficial] Websocket session starting. 但是starting不起来,用户主动在dashboard-机器人-启用 开关手动重启机器人平台后恢复,但大概30-40小时后又会原样复发。运行一百小时内触发了三次

出错时不断尝试 第二次单方向失联-1113-0103 第三次失联 第一次失联
如何复现?

使用uv tool install 部署并启动
接入QQ官方机器人
等待或正常使用30-40小时
问题出现

AstrBot 版本

4.29.4

操作系统

Linux

部署方式

uv tool install, Fedora45, python 3.15.2, uv 0.13.5

使用的消息平台适配器

QQ官方机器人(WebSocket)

错误日志
问题出现时没开Debug级别日志,只有info 级

[2026-11-12 23:25:36.288] [astrbot_plugin_fish_heart] [INFO] [astrbot_plugin_fish_heart.main:4719]: [鱼的心] 主动说话已发送(想他):喂,你会不会嫌我话多啊?有点想你了,想让你坐过来陪我说说话。
[2026-11-12 23:26:14.296] [Core] [INFO] [core.event_bus:155]: [default] [default(qq_official)] 13E646FD25BD142269F2B12BBA419986: [At:qq_official] 话多不觉得,肉麻是真的有点
[2026-11-12 23:26:15.589] [astrbot_plugin_topic_router_pro] [INFO] [astrbot_plugin_topic_router_pro.router:1370]: [astrbot_plugin_topic_router_pro] hook_llm_request_v017 被调用 | v0.8.6 | has_event=True | has_request=True | args=['QQOfficialMessageEvent', 'ProviderRequest'] | kwargs=[]
[2026-11-12 23:26:16.990] [astrbot_plugin_topic_router_pro] [INFO] [astrbot_plugin_topic_router_pro.router:868]: [astrbot_plugin_topic_router_pro] CONTINUE | default:FriendMessage:13E646FD25BD142269F2B12BBA419986 | confidence=0.55 | source=llm | topic=考试与考后心情 | msg=话多不觉得,肉麻是真的有点 | 延续闲聊的吐槽回应,未开启独立新话题(启发式:距上一条消息已过 73 分钟(阈值 45):时间长只是弱信号,交模型判下一句是否延续) | {'heuristic': 'continue', 'heuristic_confidence': 0.5, 'needs_llm': True, 'llm_used': True, 'mode': 'mark', 'has_reply': False, 'cost_ms': 1400}
[2026-11-12 23:26:17.023] [astrbot_plugin_LLMPerception] [INFO] [astrbot_plugin_LLMPerception.main:430]: 已添加感知信息: 发送时间: 2026-11-12 23:26:17 | 周四, 工作日, 深夜 | 平台: qq_official, 私聊
[2026-11-12 23:26:17.053] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [主链] 已约束被动回复的 send_message_to_user 仅用于媒体投递: session=default:FriendMessage:13E646FD25BD142269F2B12BBA419986
[2026-11-12 23:26:17.141] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [LLM工具动作] [ReactionExpression] {"trace_id":"29f43af92771","stage":"authorization","decision":"scoped","reason":"media_tools_scoped","scope":"private"}
[2026-11-12 23:26:17.142] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [被动状态管线] 已注入被动状态提示词到 default:FriendMessage:13E646FD25BD142269F2B12BBA419986: mode=light state_mode=delta reason=changed placement=system_prompt+extra_user_content_parts chars=2035 状态=心理能量=75/100|情绪底色=平稳;当前日程=(暂无);已核实当前活动=(暂无);当前计划时段=(暂无)
[2026-11-12 23:26:17.143] [astrbot_plugin_fish_heart] [INFO] [astrbot_plugin_fish_heart.main:5729]: [鱼的心][影响] {"ts": "2026-11-12 23:26:17", "channel": "private", "source": "owner", "speaker": "13E646FD25BD142269F2", "sender_id": "13E646FD25BD142269F2B12BBA419986", "is_owner": true, "bound_owner": true, "text": "话多不觉得,肉麻是真的有点", "weight": 1.0, "events": ["reply_fast", "user_msg"], "events_cn": ["及时回", "说话"], "event_log": [{"event": "reply_fast", "event_cn": "及时回", "applied": {"attachment": 0.9003350391021598, "stress": -3.6798123093980344, "intimacy": 0.5710418685255689, "expectation": -40.0, "joy": 1.556270301683746}}, {"event": "user_msg", "event_cn": "说话", "applied": {"social": 0.7749422128142243, "joy": 0.3735048724040979, "curiosity": 0.21001233042183998, "fatigue": 0.520454505849937, "intimacy": 0.02798105155775943}}], "skipped": [], "thought_settled": {"kind": "praise", "mood": "被他夸了,心里甜甜的"}, "woken": false, "negative": false, "before": {"blame": 0.0, "expectation": 40.0, "mode": "calm", "mood": "黏人", "desire": 0.0, "desire_awakened": false, "drives": {"attachment": 77.49, "curiosity": 58.0, "reflection": 50.18, "duty": 50.03, "social": 56.95, "fatigue": 26.52, "intimacy": 71.45, "stress": 3.68, "joy": 61.09}}, "after": {"blame": 0.0, "expectation": 0.0, "mode": "calm", "mood": "黏人", "desire": 0.0, "desire_awakened": false, "drives": {"attachment": 79.39, "curiosity": 58.21, "reflection": 50.18, "duty": 50.03, "social": 57.72, "fatigue": 27.04, "intimacy": 75.05, "stress": 0.0, "joy": 68.02}}, "applied_total": {"blame": 0.0, "expectation": -40.0, "desire": 0.0, "drives": {"attachment": 1.9, "curiosity": 0.21, "social": 0.77, "fatigue": 0.52, "intimacy": 3.6, "stress": -3.68, "joy": 6.93}}, "turn_mode_before": "calm", "turn_mode_after": "calm"}
[2026-11-12 23:26:23.493] [astrbot_plugin_memory_companion] [INFO] [core.service:5045]: [MemoryCompanion] 已补齐记忆向量索引: provider=Qwen/Qwen3-VL-Embedding-8B count=1
[2026-11-12 23:26:23.787] [astrbot_plugin_memory_companion] [INFO] [core.service:10027]: [MemoryCompanion] 已注入当前轮记忆: session=default:FriendMessage:13E646FD25BD142269F2B12BBA419986 snapshot=context:c99b9cefd826:9ab03c2f0d5a1d63 count=3 chars=1421
[2026-11-12 23:26:23.809] [astrbot_plugin_memory_companion] [INFO] [core.service:7018]: [MemoryCompanion] recall guidance offered: turn=69d93e1cfcbf002655f209a950a3fcaf592e03ece04175ea25f251aee77b6667 request_tools_at_memory_hook=memory_companion_events,memory_companion_navigate,memory_companion_query,memory_companion_recall,memory_companion_sources
[2026-11-12 23:26:23.840] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] [SendTracking] send wrapper installed: event=140409368125008
[2026-11-12 23:26:23.841] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] [SendTracking] send_streaming wrapper installed: event=140409368125008
[2026-11-12 23:26:25.438] [meme_manager] [INFO] [mixins.event_handlers:2101]: [meme_manager] 去重后的最终表情列表: []
[2026-11-12 23:26:26.127] [Core] [INFO] [respond.stage:237]: Prepare to send - /13E646FD25BD142269F2B12BBA419986: 嗯,那我把肉麻的收走了,免得你一晚上不自在。 我是在理抽屉,结果越理越乱,算了。
[2026-11-12 23:26:31.047] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] 已将实际发送回复交给 AstrBot 核心保存: default:FriendMessage:13E646FD25BD142269F2B12BBA419986
[2026-11-12 23:58:38.384] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:11:17.175] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:15:29.180] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:05.180] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:10.269] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:15.301] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:20.540] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:26.450] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:31.554] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:36.752] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 00:21:41.785] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.

40 minutes later……

[2026-11-13 01:01:21.521] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:26.550] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:31.581] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:39.732] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:46.674] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:51.706] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:01:56.736] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:01.785] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:07.050] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:10.929] [Core] [WARN] [v4.29.4] [sources.request_retry:68]: [OpenAI] Request failed with retryable error; retrying (2/5): APITimeoutError: Request timed out.
[2026-11-13 01:02:12.081] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:13.782] [Core] [WARN] [v4.29.4] [sources.request_retry:68]: [OpenAI] Request failed with retryable error; retrying (3/5): APIConnectionError: Connection error.
[2026-11-13 01:02:16.028] [Core] [WARN] [v4.29.4] [sources.request_retry:68]: [OpenAI] Request failed with retryable error; retrying (4/5): APIConnectionError: Connection error.
[2026-11-13 01:02:18.803] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:20.046] [Core] [WARN] [v4.29.4] [sources.request_retry:68]: [OpenAI] Request failed with retryable error; retrying (5/5): APIConnectionError: Connection error.
[2026-11-13 01:02:23.840] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:02:33.612] [astrbot_plugin_fish_heart] [INFO] [astrbot_plugin_fish_heart.main:4719]: [鱼的心] 主动说话已发送(想他):你还不困吧?嗯……今天就是有点想让你陪着,坐一会儿就好。
[2026-11-13 01:04:30.938] [Core] [INFO] [platform.manager:300]: Attempting to terminate platform adapter default ...
[2026-11-13 01:04:30.939] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:1092]: QQ 官方机器人接口 适配器已被关闭 (此处人工重启机器人)
[2026-11-13 01:04:34.652] [Core] [INFO] [platform.manager:144]: Loading IM platform adapter qq_official(default) ...
[2026-11-13 01:04:35.440] [Core] [INFO] [qqofficial.qqofficial_platform_adapter:304]: [QQOfficial] Websocket session starting.
[2026-11-13 01:04:43.612] [Core] [INFO] [core.event_bus:155]: [default] [default(qq_official)] 13E646FD25BD142269F2B12BBA419986: [At:qq_official] 在吗
[2026-11-13 01:04:44.935] [astrbot_plugin_topic_router_pro] [INFO] [astrbot_plugin_topic_router_pro.router:1370]: [astrbot_plugin_topic_router_pro] hook_llm_request_v017 被调用 | v0.8.6 | has_event=True | has_request=True | args=['QQOfficialMessageEvent', 'ProviderRequest'] | kwargs=[]
[2026-11-13 01:04:46.130] [astrbot_plugin_topic_router_pro] [INFO] [astrbot_plugin_topic_router_pro.router:868]: [astrbot_plugin_topic_router_pro] CONTINUE | default:FriendMessage:13E646FD25BD142269F2B12BBA419986 | confidence=0.60 | source=llm | topic=考试与考后闲聊 | msg=在吗 | 「在吗」只是确认在线的招呼,未开启新话题(启发式:距上一条消息已过 98 分钟(阈值 45):时间长只是弱信号,交模型判下一句是否延续) | {'heuristic': 'continue', 'heuristic_confidence': 0.5, 'needs_llm': True, 'llm_used': True, 'mode': 'mark', 'has_reply': False, 'cost_ms': 1192}
[2026-11-13 01:04:46.179] [astrbot_plugin_LLMPerception] [INFO] [astrbot_plugin_LLMPerception.main:430]: 已添加感知信息: 发送时间: 2026-11-13 01:04:46 | 周五, 工作日, 深夜 | 平台: qq_official, 私聊
[2026-11-13 01:04:46.226] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [主链] 已约束被动回复的 send_message_to_user 仅用于媒体投递: session=default:FriendMessage:13E646FD25BD142269F2B12BBA419986
[2026-11-13 01:04:47.244] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [LLM工具动作] [ReactionExpression] {"trace_id":"b40da89e0173","stage":"authorization","decision":"scoped","reason":"media_tools_scoped","scope":"private"}
[2026-11-13 01:04:47.251] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [被动状态管线] 已注入被动状态提示词到 default:FriendMessage:13E646FD25BD142269F2B12BBA419986: mode=light state_mode=delta reason=changed placement=system_prompt+extra_user_content_parts chars=2077 状态=心理能量=65/100|情绪底色=恍惚;当前日程=(暂无);已核实当前活动=(暂无);当前计划时段=(暂无)
[2026-11-13 01:04:47.253] [astrbot_plugin_fish_heart] [INFO] [astrbot_plugin_fish_heart.main:5729]: [鱼的心][影响] {"ts": "2026-11-13 01:04:47", "channel": "private", "source": "owner", "speaker": "13E646FD25BD142269F2", "sender_id": "13E646FD25BD142269F2B12BBA419986", "is_owner": true, "bound_owner": true, "text": "在吗", "weight": 1.0, "events": ["reply_fast", "user_msg"], "events_cn": ["及时回", "说话"], "event_log": [{"event": "reply_fast", "event_cn": "及时回", "applied": {"attachment": 0.7451806605815534, "stress": -2.139375, "intimacy": 0.5052536245099617, "expectation": -40.0, "joy": 1.3819006103107654}}, {"event": "user_msg", "event_cn": "说话", "applied": {"social": 0.7873894866716711, "joy": 0.33165614647458597, "curiosity": 0.2108108418222585, "fatigue": 0.5219035079072292, "intimacy": 0.024757427600988535}}], "skipped": [], "thought_settled": {"kind": "hug", "mood": "被抱了一下,整个人都松了"}, "woken": false, "negative": false, "before": {"blame": 0.0, "expectation": 40.0, "mode": "calm", "mood": "黏人", "desire": 0.0, "desire_awakened": false, "drives": {"attachment": 81.37, "curiosity": 57.84, "reflection": 50.16, "duty": 50.03, "social": 56.26, "fatigue": 26.03, "intimacy": 74.74, "stress": 2.14, "joy": 65.45}}, "after": {"blame": 0.0, "expectation": 0.0, "mode": "calm", "mood": "黏人", "desire": 0.0, "desire_awakened": false, "drives": {"attachment": 84.12, "curiosity": 58.05, "reflection": 50.16, "duty": 50.03, "social": 57.04, "fatigue": 26.55, "intimacy": 77.77, "stress": 0.0, "joy": 70.67}}, "applied_total": {"blame": 0.0, "expectation": -40.0, "desire": 0.0, "drives": {"attachment": 2.75, "curiosity": 0.21, "social": 0.78, "fatigue": 0.52, "intimacy": 3.03, "stress": -2.14, "joy": 5.22}}, "turn_mode_before": "calm", "turn_mode_after": "calm"}
[2026-11-13 01:04:50.615] [astrbot_plugin_memory_companion] [INFO] [core.service:10027]: [MemoryCompanion] 已注入当前轮记忆: session=default:FriendMessage:13E646FD25BD142269F2B12BBA419986 snapshot=context:c99b9cefd826:15c2d3cfb7b8f7e8 count=0 chars=1205
[2026-11-13 01:04:50.630] [astrbot_plugin_memory_companion] [INFO] [core.service:7018]: [MemoryCompanion] recall guidance offered: turn=246468e8eaba8797b829cd624608d9b314cd6306e169e0e3c80841fcf6b9062b request_tools_at_memory_hook=memory_companion_events,memory_companion_navigate,memory_companion_query,memory_companion_recall,memory_companion_sources
[2026-11-13 01:04:50.649] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] [SendTracking] send wrapper installed: event=140409369924368
[2026-11-13 01:04:50.649] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] [SendTracking] send_streaming wrapper installed: event=140409369924368
[2026-11-13 01:04:52.363] [meme_manager] [INFO] [mixins.event_handlers:2101]: [meme_manager] 去重后的最终表情列表: []
[2026-11-13 01:04:53.151] [Core] [INFO] [respond.stage:237]: Prepare to send - /13E646FD25BD142269F2B12BBA419986: 在的。 你还没睡呀? 我刚迷迷糊糊醒了一下,正愣着呢。
[2026-11-13 01:05:05.028] [astrbot_plugin_private_companion] [INFO] [astrbot_plugin_private_companion.logging_util:139]: [回复持久化] 已将实际发送回复交给 AstrBot 核心保存: default:FriendMessage:13E646FD25BD142269F2B12BBA419986
辅助信息

重启机器人后的日志.zip
重启机器人前的日志.zip

检查清单
  • 我已在 Issue 列表中搜索过相关问题仍无法解决,或该问题从未被报告过。
  • 我已尝试过禁用所有插件,排除了可能是因插件导致的问题。
  • 我报告的问题与 AstrBot 本体相关,而非在报告某一插件的问题。
  • 我已阅读并同意本项目的贡献者行为准则。
  • (可选)我愿意提交 PR 以帮助修复该问题。
主要言語
Python
スター
46.9k
フォーク
3.6k
平均マージ
1日 5時間
マージ済み PR(30日)
140

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AstrBotDevs/AstrBot のほかの issue

AstrBotDevs/AstrBot の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。