kyubotics / coolq-http-api

为 酷Q 提供通过 HTTP 或 WebSocket 接收事件和调用 API 的能力
https://cqhttp.cc/docs/
GNU General Public License v3.0
1.85k stars 308 forks source link

酷Q运行一段时间后http插件上报消息后无法接受到请求 #352

Closed Fly-Potato closed 4 years ago

Fly-Potato commented 4 years ago

插件使用的nonebot,然后在刚启动酷Q的20分钟内运行无异常,但过了一段时间后,nonebot能收到消息,但在发送后,http插件无法收到

下面是最后一段日志: [2020-07-08 12:25:04.001] [D] [WS API] 开始执行动作 send_msg [2020-07-08 12:25:04.107] [D] [WS API] 动作 send_msg 执行成功 [2020-07-08 12:25:04.107] [D] [WS API] 响应数据已准备完毕:{"data":{"message_id":37},"echo":{"seq":31},"retcode":0,"status":"ok"} [2020-07-08 12:25:04.107] [D] [WS API] 响应内容已发送 [2020-07-08 12:25:04.108] [I] [WS API] 已成功处理一个 API 请求:send_msg [2020-07-08 12:34:14.564] [D] [反向WS] 开始通过反向 WebSocket 客户端上报事件 [2020-07-08 12:34:14.564] [I] [反向WS] 通过反向 WebSocket 客户端上报数据到 ws://cq.flypotato.com:8080/ws/ 成功 [2020-07-08 12:34:14.666] [D] [WS API] 收到 API 请求:{"action": "get_version_info", "params": {}, "echo": {"seq": 32}} [2020-07-08 12:34:14.667] [D] [WS API] 开始执行动作 get_version_info [2020-07-08 12:34:14.667] [D] [WS API] 动作 get_version_info 执行成功 [2020-07-08 12:34:14.667] [D] [WS API] 响应数据已准备完毕:{"data":{"coolq_directory":"E:\酷Q Air\","coolq_edition":"air","plugin_build_configuration":"release","plugin_build_number":441,"plugin_version":"4.15.0"},"echo":{"seq":32},"retcode":0,"status":"ok"} [2020-07-08 12:34:14.668] [D] [WS API] 响应内容已发送 [2020-07-08 12:34:14.668] [I] [WS API] 已成功处理一个 API 请求:get_version_info [2020-07-08 12:34:14.770] [D] [WS API] 收到 API 请求:{"action": "send_msg", "params": {"message_type": "private", "user_id": 1006186250, "message": "\u5168\u670d\u82b1\u4ef7\uff1a\nhttps://ws.xoyo.com/_daily_flower/flower/share"}, "echo": {"seq": 33}} [2020-07-08 12:34:14.771] [D] [WS API] 开始执行动作 send_msg [2020-07-08 12:34:14.922] [D] [WS API] 动作 send_msg 执行成功 [2020-07-08 12:34:14.922] [D] [WS API] 响应数据已准备完毕:{"data":{"message_id":39},"echo":{"seq":33},"retcode":0,"status":"ok"} [2020-07-08 12:34:14.922] [D] [WS API] 响应内容已发送 [2020-07-08 12:34:14.922] [I] [WS API] 已成功处理一个 API 请求:send_msg [2020-07-08 14:13:10.969] [D] [反向WS] 开始通过反向 WebSocket 客户端上报事件 [2020-07-08 14:13:10.969] [I] [反向WS] 通过反向 WebSocket 客户端上报数据到 ws://cq.flypotato.com:8080/ws/ 成功

14点13分的命令只上报了,但是没有收到请求,nonebot用的阿里云的vps

Fly-Potato commented 4 years ago

File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiocqhttp/api_impl.py", line 118, in fetch return await asyncio.wait_for(future, timeout_sec) File "/root/.pyenv/versions/3.8.2/lib/python3.8/asyncio/tasks.py", line 490, in wait_for raise exceptions.TimeoutError() asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/nonebot/command/init.py", line 723, in _real_run_command await asyncio.wait_for(future, timeout) File "/root/.pyenv/versions/3.8.2/lib/python3.8/asyncio/tasks.py", line 455, in wait_for return await fut File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/nonebot/command/init.py", line 101, in run await self.func(session) File "/root/jx3_helper/jx3/plugins/flower.py", line 14, in flower version_info = await session.bot.get_version_info() File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiocqhttp/init.py", line 219, in call_action return await self._api.call_action(action=action, params) File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiocqhttp/api_impl.py", line 186, in call_action result = await self._wsr_api.call_action(action, params) File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiocqhttp/api_impl.py", line 162, in call_action await ResultStore.fetch(seq, self._timeout_sec)) File "/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiocqhttp/api_impl.py", line 122, in fetch raise NetworkError('WebSocket API call timeout') aiocqhttp.exceptions.NetworkError: WebSocket API call timeout

nonebot这边说超时了

stdrc commented 4 years ago

可能连接被掐了或者网络不稳定,不建议走公网上报和调用 API,如果一定要走公网,尝试打开心跳功能(enable_heartbeat 配置项,具体见文档)