Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 对接mirai时出现报错 #1378

Open
Bio233 opened this issue Nov 23, 2024 · 4 comments
Open

[BUG] 对接mirai时出现报错 #1378

Bio233 opened this issue Nov 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Bio233
Copy link

Bio233 commented Nov 23, 2024

提交 issue 前,请先确认:

  • [√] 我已看过 FAQ,此问题不在列表中
  • [√] 我已看过其他 issue,他们不能解决我的问题
  • [√] 我认为这不是 Mirai 或者 OpenAI 的 BUG

表现
描述 BUG 的表现情况

运行环境:

  • 操作系统:win11
  • Docker: ?
  • 项目版本:Windows-quickstart-mirai-refs.tags.v2.5.3

复现步骤
描述你是如何触发这个 BUG 的
采用反向连接,mirai等待对接时启动gpt,gpt和mirai出现如下报错

预期行为
连接成功

截图

2024-11-23 15:35:42.349 | INFO | launart.manager:_launchable_task_done_callback:69 - [elizabeth.connection.3433779255.websocket_server_connection] completed.
2024-11-23 15:35:42.349 | INFO | graia.amnesia.builtins.aiohttp:launch:513 - starting server on 0.0.0.0:8554
2024-11-23 15:35:42.362 | SUCCESS | launart.manager:launch:385 - Layer #1:[http.server/aiohttp, cache.client/memcache, http.client/aiohttp] preparation completed.
2024-11-23 15:35:42.363 | INFO | platforms.ariadne_bot:start_background:192 - 尝试从 Mirai 服务中读取机器人 QQ 的 session key……
2024-11-23 15:35:42.363 | INFO | platforms.ariadne_bot:start_background:194 - [提示] 当前为反向 ws 模式,请确保你的 mirai api http 设置了正确的 reverse-ws adapter 配置
2024-11-23 15:35:42.363 | INFO | platforms.ariadne_bot:start_background:195 - [提示] 配置不正确会导致 Mirai 端出现错误提示。
2024-11-23 15:35:42.363 | SUCCESS | launart.manager:launch:385 - Layer #3:[elizabeth.service] preparation completed.
2024-11-23 15:35:42.363 | INFO | launart.manager:launch:390 - All components prepared, start blocking phase.
2024-11-23 15:35:42.977 | INFO | main::52 - [Edge TTS] 读取成功!
2024-11-23 15:35:47.254 | ERROR | graia.amnesia.transport.rider:trigger_callbacks:37 - Host 'localhost:8554' cannot contain ':' (at position 9)
Traceback (most recent call last):

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\graia\ariadne\connection\ws.py", line 142, in _
req: HttpRequest = await io.extra(HttpRequest)
│ │ └ <class 'graia.amnesia.transport.common.http.extra.HttpRequest'>
│ └ <function AiohttpServerWebsocketIO.extra at 0x000001E2417CB9A0>
└ <graia.amnesia.builtins.aiohttp.AiohttpServerWebsocketIO object at 0x000001E26A560EB0>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\graia\amnesia\builtins\aiohttp.py", line 386, in extra
self.request.url,
│ │ └ <aiohttp._helpers.reify object at 0x000001E241727490>
│ └ <Request GET / >
└ <graia.amnesia.builtins.aiohttp.AiohttpServerWebsocketIO object at 0x000001E26A560EB0>

File "aiohttp_helpers.pyx", line 26, in aiohttp._helpers.reify.get
val = self.wrapped(inst)

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\aiohttp\web_request.py", line 437, in url
url = URL.build(scheme=self.scheme, host=self.host)
│ │ │ │ │ └ <aiohttp._helpers.reify object at 0x000001E2417279D0>
│ │ │ │ └ <Request GET / >
│ │ │ └ <aiohttp._helpers.reify object at 0x000001E241725540>
│ │ └ <Request GET / >
│ └ <classmethod(<function URL.build at 0x000001E24135EDD0>)>
└ <class 'yarl.URL'>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\yarl_url.py", line 387, in build
_host = _encode_host(host, validate_host=True)
│ └ 'localhost:8554'
└ <functools._lru_cache_wrapper object at 0x000001E2413A1A60>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\yarl_url.py", line 1476, in _encode_host
raise ValueError(

ValueError: Host 'localhost:8554' cannot contain ':' (at position 9)
2024-11-23 15:35:47.260 | INFO | graia.ariadne.connection.ws:_:92 - Websocket connection closed
2024-11-23 15:35:47.261 | ERROR | graia.ariadne.util:loguru_exc_callback:76 - Exception:
Traceback (most recent call last):

File "E:\TOOL\GPT_mirai\chatgpt-mirai-qq-bot\bot.py", line 58, in
loop.run_until_complete(asyncio.gather(*bots))
│ │ │ │ └ [<Task pending name='Task-2' coro=<start_task() running at E:\TOOL\GPT_mirai\chatgpt-mirai-qq-bot\platforms\ariadne_bot.py:33...
│ │ │ └ <function gather at 0x000001E24076B400>
│ │ └ <module 'asyncio' from 'C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\init.py'>
│ └ <function BaseEventLoop.run_until_complete at 0x000001E24078C0D0>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 636, in run_until_complete
self.run_forever()
│ └ <function ProactorEventLoop.run_forever at 0x000001E24080A9E0>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
│ └ <function BaseEventLoop._run_once at 0x000001E24078DB40>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\base_events.py", line 1909, in _run_once
handle._run()
│ └ <function Handle._run at 0x000001E23EF58EE0>
└ <Handle Task.task_wakeup(<_GatheringFu...result=[None]>)>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
│ │ │ │ │ └ <member '_args' of 'Handle' objects>
│ │ │ │ └ <Handle Task.task_wakeup(<_GatheringFu...result=[None]>)>
│ │ │ └ <member '_callback' of 'Handle' objects>
│ │ └ <Handle Task.task_wakeup(<_GatheringFu...result=[None]>)>
│ └ <member '_context' of 'Handle' objects>
└ <Handle Task.task_wakeup(<_GatheringFu...result=[None]>)>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\aiohttp\web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
│ └ <Request GET / >
└ <bound method Application._handle of <Application 0x1e26a441570>>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\aiohttp\web_app.py", line 504, in _handle
resp = await handler(request)
│ └ <Request GET / >
└ <bound method AiohttpRouter.handle_websocket_request of <graia.amnesia.builtins.aiohttp.AiohttpRouter object at 0x000001E26A4...

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\graia\amnesia\builtins\aiohttp.py", line 468, in handle_websocket_request
await websocket_io.close()
│ └ <function AiohttpServerWebsocketIO.close at 0x000001E2417CBC70>
└ <graia.amnesia.builtins.aiohttp.AiohttpServerWebsocketIO object at 0x000001E26A560EB0>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\graia\amnesia\builtins\aiohttp.py", line 411, in close
await self.websocket.close()
│ │ └ <function WebSocketResponse.close at 0x000001E2417AF6D0>
│ └
└ <graia.amnesia.builtins.aiohttp.AiohttpServerWebsocketIO object at 0x000001E26A560EB0>

File "C:\Users\Bio\Miniconda3\envs\chatgpt\lib\site-packages\aiohttp\web_ws.py", line 337, in close
raise RuntimeError("Call .prepare() first")

RuntimeError: Call .prepare() first
ERROR:aiohttp.server:Error handling request

image

其他内容
此处填写其他内容,没有可跳过

@Bio233 Bio233 added the bug Something isn't working label Nov 23, 2024
@Bio233
Copy link
Author

Bio233 commented Nov 23, 2024

提交 issue 前,请先确认:

  • [√] 我已看过 FAQ,此问题不在列表中
  • [√] 我已看过其他 issue,他们不能解决我的问题
  • [√] 我认为这不是 Mirai 或者 OpenAI 的 BUG

表现 描述 BUG 的表现情况

运行环境:

  • 操作系统:win11
  • Docker: ?
  • 项目版本:Windows-quickstart-mirai-refs.tags.v2.5.3

复现步骤 描述你是如何触发这个 BUG 的 采用反向连接,mirai等待对接时启动gpt,gpt和mirai出现如下报错

预期行为 连接成功

截图

image
image
image
image

image

其他内容 此处填写其他内容,没有可跳过

@hapa3
Copy link

hapa3 commented Nov 26, 2024

同样的问题

@sanxianxiaohuntun
Copy link

问题 1: ValueError: Host 'localhost:8554' cannot contain ':'
是因为在 localhost:8554 中的 : 被认为是无效字符。你可以尝试写成127.0.0.1:8554
问题 2: RuntimeError: Call .prepare() first
这个问题发生在尝试关闭 WebSocket 连接时,提示在调用 close 之前,应该先调用 .prepare() 方法。这通常是因为在处理 WebSocket 请求时,aiohttp 的 WebSocketResponse 对象没有被正确初始化。

@Ghostlikes
Copy link

问题 1: ValueError: Host 'localhost:8554' cannot contain ':' 是因为在 localhost:8554 中的 : 被认为是无效字符。你可以尝试写成127.0.0.1:8554 问题 2: RuntimeError: Call .prepare() first 这个问题发生在尝试关闭 WebSocket 连接时,提示在调用 close 之前,应该先调用 .prepare() 方法。这通常是因为在处理 WebSocket 请求时,aiohttp 的 WebSocketResponse 对象没有被正确初始化。

请问问题一应该在哪个文件修改呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants