Yuri-YuzuChaN / nonebot-plugin-maimaidx

街机音游 舞萌DX 的 nonebot2 插件
MIT License
65 stars 9 forks source link

WebSocketDisconnect 1006 #43

Closed gzx7301 closed 1 month ago

gzx7301 commented 1 month ago

大家好啊我又来了

09-21 00:02:43 [ERROR] nonebot | Running Matcher(type='message', module=plugins.nonebot_plugin_maimaidx.command.mai_score, lineno=14) failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 332, in asgi_send
    await self.send(data)  # type: ignore[arg-type]
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 647, in send
    await self.write_frame(True, opcode, data)
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1209, in write_frame
    await self.drain()
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1198, in drain
    await self.ensure_open()
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 939, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/starlette/websockets.py", line 97, in send
    await self._send(message)
  File "/usr/local/lib/python3.9/dist-packages/starlette/_exception_handler.py", line 50, in sender
    await send(message)
  File "/usr/local/lib/python3.9/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 345, in asgi_send
    raise ClientDisconnected from exc
uvicorn.protocols.utils.ClientDisconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/nonebot/message.py", line 476, in check_and_run_matcher
    await _run_matcher(
> File "/usr/local/lib/python3.9/dist-packages/nonebot/message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 850, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 825, in simple_run
    await handler(
  File "/usr/local/lib/python3.9/dist-packages/nonebot/dependencies/__init__.py", line 94, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "/root/std/plugins/nonebot_plugin_maimaidx/command/mai_score.py", line 32, in _
    await matcher.finish(await generate(qqid, username), reply_message=True)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 582, in finish
    await cls.send(message, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/matcher/matcher.py", line 566, in send
    return await bot.send(event=event, message=_message, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/adapters/onebot/v11/bot.py", line 237, in send
    return await self.__class__.send_handler(self, event, message, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/adapters/onebot/v11/bot.py", line 190, in send
    return await bot.send_msg(**params)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/adapter/bot.py", line 122, in call_api
    raise exception
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/adapter/bot.py", line 97, in call_api
    result = await self.adapter._call_api(self, api, **data)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/adapters/onebot/v11/adapter.py", line 145, in _call_api
    await websocket.send(json_data)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/internal/driver/model.py", line 193, in send
    await self.send_text(data)
  File "/usr/local/lib/python3.9/dist-packages/nonebot/drivers/fastapi.py", line 301, in send_text
    await self.websocket.send({"type": "websocket.send", "text": data})
  File "/usr/local/lib/python3.9/dist-packages/starlette/websockets.py", line 100, in send
    raise WebSocketDisconnect(code=1006)
starlette.websockets.WebSocketDisconnect
09-21 00:02:43 [INFO] websockets | connection closed
09-21 00:02:43 [WARNING] nonebot | OneBot V11 | WebSocket for Bot 2408367481 closed by peer

15日晚间出现此类问题 有时获取B50需要1分钟及以上的延迟 有时会发生上文的报错

VPS IP 38.150.. 已开启IPV4优先 网络环境可正常 wget https://www.diving-fish.com/api/maimaidxprober/music_data 并获得music_data.json image 使用的版本是 c3ba722 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux

gzx7301 commented 1 month ago

前端 shamrock 1.0.7-dev.6201d12 - Xpoed bd35853f80b056c33e9513dce19da224

Yuri-YuzuChaN commented 1 month ago

查分器服务器在香港,获取b50超时得自己查网络问题

gzx7301 commented 1 month ago

尝试使用

   --method POST \
   --timeout=0 \
   --header 'Content-Type: application/json' \
   --header 'Accept: */*' \
   --header 'Host: www.diving-fish.com' \
   --header 'Connection: keep-alive' \
   --body-data '{
    "qq": 1537324535,
    "username": "gzx7301"
}' \
    'https://www.diving-fish.com/api/maimaidxprober/query/player'

后可以正常获取到player文件 文件内容也是正确的 不像是网络问题吧...

Yuri-YuzuChaN commented 1 month ago

我看了下你的log,好像是你的bot客户端与shamrock传输超时,maimai插件不用websocket,用的httpx模块仅使用http访问

Yuri-YuzuChaN commented 1 month ago

最上面的一个Traceback在发送消息的时候超时

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 332, in asgi_send
    await self.send(data)  # type: ignore[arg-type]
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 647, in send
    await self.write_frame(True, opcode, data)
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1209, in write_frame
    await self.drain()
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 1198, in drain
    await self.ensure_open()
  File "/usr/local/lib/python3.9/dist-packages/websockets/legacy/protocol.py", line 939, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent
gzx7301 commented 1 month ago

看到了~谢谢 我这边检查确认了一下 确实是nonebot和shamrock之间的连接问题 我这边尝试换了FastApi+WebSocker驱动器目前改善了 希望他能多跑一阵吧