Closed QSlotus closed 7 months ago
Ubuntu 22.04 LTS,Python3.10.12,Paper 1.16.5
1.2.7
我按照 此教程 部署了nonebot前端与mirai后端,成功连接。 然后按照文档安装了nonebot-plugin-mcqq插件,运行nonebot,成功。 (同时在服务器上安装了配套插件,并修改了配置文件 目前为止一切正常,但是当我登入服务器并且发送一条消息后,nonebot报错并且每发一条消息websocket连接就会断开一次
nonebot-plugin-mcqq
bot.py文件内容:
bot.py
import nonebot from nonebot.adapters.mirai2 import Adapter as Mirai2Adapter # 避免重复命名 # 初始化 NoneBot nonebot.init() # 注册适配器 driver = nonebot.get_driver() driver.register_adapter(Mirai2Adapter) # 在这里加载插件 nonebot.load_builtin_plugins("echo") # 内置插件 nonebot.load_from_toml("pyproject.toml", encoding="utf-8") # nonebot.load_plugins("awesome_bot/plugins") # 本地插件 if __name__ == "__main__": nonebot.run()
Nonebot日志: root@seryoBS8XBzqiL1:/data/mcqqq# nb run 12-31 11:47:13 [SUCCESS] nonebot | NoneBot is initializing... 12-31 11:47:13 [INFO] nonebot | Current Env: prod 12-31 11:47:14 [SUCCESS] nonebot | Succeeded to load plugin "echo" from "nonebot.plugins.echo" 12-31 11:47:14 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_guild_patch" 12-31 11:47:14 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_mcqq" 12-31 11:47:14 [SUCCESS] nonebot | Running NoneBot... 12-31 11:47:14 [INFO] uvicorn | Started server process [1614] 12-31 11:47:14 [INFO] uvicorn | Waiting for application startup. 12-31 11:47:14 [SUCCESS] nonebot_plugin_mcqq | [MC_QQ]丨WebSocket 服务器已启动,路由:/onebot/v11/mcqq 12-31 11:47:14 [INFO] uvicorn | Application startup complete. 12-31 11:47:14 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:8093 (Press CTRL+C to quit) 12-31 11:47:14 [INFO] nonebot | mirai2 | Bot 1759585224 connected 12-31 11:48:37 [INFO] uvicorn | ('127.0.0.1', 56948) - "WebSocket /onebot/v11/mcqq" [accepted] 12-31 11:48:37 [SUCCESS] nonebot_plugin_mcqq | [MC_QQ]丨[Server:昕夕亭] 已连接至 WebSocket 服务器 12-31 11:48:37 [INFO] websockets | connection open 12-31 11:49:59 [INFO] mcqq_tool | [MC_QQ]丨[Server:昕夕亭] 的 WebSocket 客户端已移除 12-31 11:49:59 [ERROR] uvicorn | Exception in ASGI application Traceback (most recent call last): File "/data/mcqqq/bot.py", line 18, in <module> nonebot.run() File "/usr/local/lib/python3.10/dist-packages/nonebot/__init__.py", line 331, in run get_driver().run(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 189, in run uvicorn.run( File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 587, in run server.run() File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) > File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 116, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 151, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 746, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 357, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 94, in app await wrap_app_handling_exceptions(app, session)(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 92, in app await func(session) File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 360, in app await dependant.call(**values) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 146, in _handle await self._handle_ws(websocket, setup) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 255, in _handle_ws await setup.handle_func(ws) File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_mcqq/data_source.py", line 52, in _ws_handler await send_msg_from_mc_common(message=message) File "/usr/local/lib/python3.10/dist-packages/mcqq_tool/utils/parse/parse_mc_msg.py", line 48, in send_msg_from_mc_common event = event_dict[json_msg["event_name"]].parse_obj(json_msg) File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj return cls(**obj) File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ raise validation_error pydantic.error_wrappers.ValidationError: 1 validation error for PlayerJoinEvent timestamp field required (type=value_error.missing) 12-31 11:49:59 [INFO] websockets | connection closed 12-31 11:50:02 [INFO] uvicorn | ('127.0.0.1', 35560) - "WebSocket /onebot/v11/mcqq" [accepted] 12-31 11:50:02 [SUCCESS] nonebot_plugin_mcqq | [MC_QQ]丨[Server:昕夕亭] 已连接至 WebSocket 服务器 12-31 11:50:02 [INFO] websockets | connection open 12-31 11:50:09 [INFO] mcqq_tool | [MC_QQ]丨[Server:昕夕亭] 的 WebSocket 客户端已移除 12-31 11:50:09 [ERROR] uvicorn | Exception in ASGI application Traceback (most recent call last): File "/data/mcqqq/bot.py", line 18, in <module> nonebot.run() File "/usr/local/lib/python3.10/dist-packages/nonebot/__init__.py", line 331, in run get_driver().run(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 189, in run uvicorn.run( File "/usr/local/lib/python3.10/dist-packages/uvicorn/main.py", line 587, in run server.run() File "/usr/local/lib/python3.10/dist-packages/uvicorn/server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) > File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 250, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 1054, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 116, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 151, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 746, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 357, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 94, in app await wrap_app_handling_exceptions(app, session)(scope, receive, send) File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 55, in wrapped_app raise exc File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 44, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 92, in app await func(session) File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 360, in app await dependant.call(**values) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 146, in _handle await self._handle_ws(websocket, setup) File "/usr/local/lib/python3.10/dist-packages/nonebot/drivers/fastapi.py", line 255, in _handle_ws await setup.handle_func(ws) File "/usr/local/lib/python3.10/dist-packages/nonebot_plugin_mcqq/data_source.py", line 52, in _ws_handler await send_msg_from_mc_common(message=message) File "/usr/local/lib/python3.10/dist-packages/mcqq_tool/utils/parse/parse_mc_msg.py", line 48, in send_msg_from_mc_common event = event_dict[json_msg["event_name"]].parse_obj(json_msg) File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj return cls(**obj) File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ raise validation_error pydantic.error_wrappers.ValidationError: 1 validation error for AsyncPlayerChatEvent timestamp field required (type=value_error.missing) 12-31 11:50:09 [INFO] websockets | connection closed 12-31 11:50:12 [INFO] uvicorn | ('127.0.0.1', 38118) - "WebSocket /onebot/v11/mcqq" [accepted] 12-31 11:50:12 [SUCCESS] nonebot_plugin_mcqq | [MC_QQ]丨[Server:昕夕亭] 已连接至 WebSocket 服务器 12-31 11:50:12 [INFO] websockets | connection open ^C12-31 11:50:34 [INFO] uvicorn | Shutting down 12-31 11:50:34 [WARNING] nonebot_plugin_mcqq | [MC_QQ]丨[Server:昕夕亭] 的 WebSocket 出现异常:WebSocketClosed(code=1012) 12-31 11:50:34 [INFO] mcqq_tool | [MC_QQ]丨[Server:昕夕亭] 的 WebSocket 客户端已移除 12-31 11:50:34 [INFO] websockets | connection closed 12-31 11:50:35 [INFO] uvicorn | Waiting for application shutdown. 12-31 11:50:35 [INFO] uvicorn | Application shutdown complete. 12-31 11:50:35 [INFO] uvicorn | Finished server process [1614] root@seryoBS8XBzqiL1:/data/mcqqq#
Minecraft服务器部分日志:
[11:50:02 INFO]: [MC_QQ] 已成功连接 WebSocket 服务器。 [11:50:02 INFO]: [voicechat] Successfully authenticated player 9aed2a5e-bc3d-357d-b476-e8f40d083e0b [11:50:03 INFO]: [voicechat] Successfully validated connection of player 9aed2a5e-bc3d-357d-b476-e8f40d083e0b [11:50:03 INFO]: [voicechat] Player Yanyos (9aed2a5e-bc3d-357d-b476-e8f40d083e0b) successfully connected to voice chat [11:50:09 INFO]: [MC_QQ] WebSocket 连接已断开,正在第 1 次重新连接。 [11:50:09 INFO]: <『服务器巡查者』Yanyos> 1 [11:50:12 INFO]: [MC_QQ] 已成功连接 WebSocket 服务器。 [11:50:34 INFO]: [MC_QQ] WebSocket 连接已断开,正在第 1 次重新连接。 [11:50:37 INFO]: [MC_QQ] WebSocket 连接已断开,正在第 2 次重新连接。 [11:50:40 INFO]: [MC_QQ] WebSocket 连接已断开,正在第 3 次重新连接。 [11:50:42 INFO]: Yanyos lost connection: Disconnected [11:50:42 INFO]: [MC_QQ] 发送消息失败,没有连接到 WebSocket 服务器。 [11:50:42 INFO]: [voicechat] Disconnecting client Yanyos [11:50:42 INFO]: Yanyos left the game
并未适配mirai适配器
建议你使用OneBot适配器或QQ适配器
运行环境
Ubuntu 22.04 LTS,Python3.10.12,Paper 1.16.5
NB插件及版本号
1.2.7
MC插件及版本号
1.2.7
错误描述
我按照 此教程 部署了nonebot前端与mirai后端,成功连接。 然后按照文档安装了
nonebot-plugin-mcqq
插件,运行nonebot,成功。 (同时在服务器上安装了配套插件,并修改了配置文件 目前为止一切正常,但是当我登入服务器并且发送一条消息后,nonebot报错并且每发一条消息websocket连接就会断开一次bot.py
文件内容:报错日志(如果有)
Minecraft服务器部分日志: