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]: 初始化后出现base.py (43) - [ERROR]异常 #609

Closed
lsx626 opened this issue Nov 21, 2023 · 7 comments
Closed

[Bug]: 初始化后出现base.py (43) - [ERROR]异常 #609

lsx626 opened this issue Nov 21, 2023 · 7 comments
Labels
bug? Bug或Bug修复相关 IM: YiriMirai mirai-api-http 协议适配器相关 重复 已存在相同的issue或PR

Comments

@lsx626
Copy link

lsx626 commented Nov 21, 2023

部署方式

安装器部署

登录框架

Mirai

系统环境

Windows Server 2019

Python环境

Python 3.10

异常情况

在mirai登录后,我启动了机器人,初始化一直失败,提示有库缺失,我在补充并安装了所需库之后,重新运行了机器人。初始化成功了,但是登录失败,控制台出现“404”的字样,此前控制台曾提示websockets库版本不对,我更新了版本之后就这样了。其实虽然更新了版本,但是websockets与yiri-mirai其实不兼容,而与yiri-mirai兼容的websockets版本又不支持python3.10。于是在运行中,出现了报错。

报错信息

C:\Users\Administrator\Desktop\bot\QChatGPT>..\python\python.exe main.py
[2023-11-21 23:47:12.983] main.py (118) - [INFO] : 检查config模块完整性.
[2023-11-21 23:47:12.984] main.py (151) - [INFO] : 检查tips模块完整性.
Database initialized.
[2023-11-21 23:47:13.816] keymgr.py (78) - [INFO] : 使用api-key:default
[2023-11-21 23:47:13.841] manager.py (239) - [INFO] : 加载禁用列表: person: [2854196310], group: [204785790, 691226829]
[2023-11-21 23:47:13.844] settings.py (98) - [INFO] : 已全局启用内容函数。
[2023-11-21 23:47:13.845] host.py (135) - [INFO] : 初始化插件
[2023-11-21 23:47:13.845] host.py (152) - [INFO] : 以下插件已初始化:
[2023-11-21 23:47:15.847] main.py (334) - [INFO] : 您正在使用Windows系统,若命令行窗口处于“选择”模式,程序可能会被暂停,此时请右键点击窗口空白区域使其取消选择模式。
2023-11-21 23:47:23 - ERROR
[2023-11-21 23:47:23.849] base.py (43) - [ERROR] :
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 659, in await_impl
await protocol.handshake(
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 328, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 668, in await_impl
await protocol.wait_closed()
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "asyncio\tasks.py", line 456, in wait_for
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\QChatGPT\main.py", line 273, in run_bot_wrapper
qqbot.adapter.run_sync()
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\qqbot\sources\yirimirai.py", line 120, in run_sync
loop.run_until_complete(MiraiRunner(self.bot)._run())
File "asyncio\base_events.py", line 649, in run_until_complete
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 238, in _run
await self.startup()
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 226, in startup
await asyncio.gather(*coros)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 135, in startup
await self._adapter.login(self.qq)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\adapters\base.py", line 35, in wrapped
return await func(self, *args, **kwargs)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\adapters\websocket.py", line 187, in login
self.connection = await connect(self.host_name, extra_headers=headers)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 650, in await_impl_timeout
return await asyncio.wait_for(self.await_impl(), self.open_timeout)
File "asyncio\tasks.py", line 458, in wait_for
asyncio.exceptions.TimeoutError
[2023-11-21 23:47:23.873] main.py (310) - [ERROR] : 捕捉到未知异常:, 请前往 https://github.com/RockChinQ/QChatGPT/issues 查找或提issue
Exception in thread Thread-2 (run_bot_wrapper):
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 659, in await_impl
await protocol.handshake(
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 328, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 668, in await_impl
await protocol.wait_closed()
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "asyncio\tasks.py", line 456, in wait_for
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
File "threading.py", line 1016, in _bootstrap_inner
File "threading.py", line 953, in run
File "C:\Users\Administrator\Desktop\bot\QChatGPT\main.py", line 313, in run_bot_wrapper
raise e
File "C:\Users\Administrator\Desktop\bot\QChatGPT\main.py", line 273, in run_bot_wrapper
qqbot.adapter.run_sync()
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\qqbot\sources\yirimirai.py", line 120, in run_sync
loop.run_until_complete(MiraiRunner(self.bot)._run())
File "asyncio\base_events.py", line 649, in run_until_complete
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 238, in _run
await self.startup()
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 226, in startup
await asyncio.gather(*coros)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\bot.py", line 135, in startup
await self._adapter.login(self.qq)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\adapters\base.py", line 35, in wrapped
return await func(self, *args, **kwargs)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\mirai\adapters\websocket.py", line 187, in login
self.connection = await connect(self.host_name, extra_headers=headers)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\websockets\legacy\client.py", line 650, in await_impl_timeout
return await asyncio.wait_for(self.await_impl(), self.open_timeout)
File "asyncio\tasks.py", line 458, in wait_for
asyncio.exceptions.TimeoutError

@lsx626 lsx626 added the bug? Bug或Bug修复相关 label Nov 21, 2023
@lsx626
Copy link
Author

lsx626 commented Nov 21, 2023

我正在考虑是否需要将3.10降到3.9

@RockChinQ
Copy link
Owner

mirai端口冲突,解决办法 #22

@RockChinQ RockChinQ added 重复 已存在相同的issue或PR IM: YiriMirai mirai-api-http 协议适配器相关 部署 labels Nov 21, 2023
@lsx626
Copy link
Author

lsx626 commented Nov 21, 2023

mirai成功运行没有问题,mirai的控制台中,有:
2023-11-22 00:17:53 I/MahKtorAdapter[http]: Responding at http://localhost:8080
2023-11-22 00:17:53 I/http adapter: >>> [http adapter] is listening at http://localhost:8080
mirai本身用的就是8080端口,登录没有问题,没有被其他程序占用。但是机器人在运行的时候还是有之前的报错

@RockChinQ
Copy link
Owner

你mirai-api-http版本不对或者没有配置ws连接方式,可能是因为安装器操作失败。你可以按照文档的手动部署方式自己重新部署一下mirai和mirai-api-http。或者考虑换用go-cqhttp。

@lsx626
Copy link
Author

lsx626 commented Nov 21, 2023

我重新配置了ws,是识别码输错了,机器人启动成功了,谢谢!
机器人启动成功,登录成功,回复报错:
[2023-11-22 01:03:06.451] message.py (130) - [ERROR] : BaseClient.build_request() got an unexpected keyword argument 'timeout'
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\qqbot\message.py", line 44, in process_normal_message
text, finish_reason, funcs = session.query(text_message)
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\openai\session.py", line 265, in query
for resp in context.get_openai_manager().request_completion(prompts):
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\openai\manager.py", line 57, in request_completion
for resp in request:
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\openai\api\chat_completion.py", line 94, in next
resp: chat_completion.ChatCompletion = self._req(**args)
File "C:\Users\Administrator\Desktop\bot\QChatGPT.\pkg\openai\api\model.py", line 27, in _req
ret = self.req_func(**kwargs)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai_utils_utils.py", line 299, in wrapper
return func(*args, **kwargs)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai\resources\chat\completions.py", line 598, in create
return self._post(
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai_base_client.py", line 1063, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai_base_client.py", line 842, in request
return self._request(
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai_base_client.py", line 862, in _request
request = self._build_request(options)
File "C:\Users\Administrator\Desktop\bot\python\lib\site-packages\openai_base_client.py", line 461, in _build_request return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
TypeError: BaseClient.build_request() got an unexpected keyword argument 'timeout'
[2023-11-22 01:03:06.475] manager.py (390) - [INFO] : 通知管理员:person_3352487028会话处理异常:BaseClient.build_request() got an unexpected keyword argument 'timeout'
[2023-11-22 01:03:07.204] process.py (155) - [INFO] : 回复[person_3352487028]文字消息:[bot]err:BaseClient.build_request() got an unexpected keyword argument 'timeout'
[2023-11-22 01:03:07.207] process.py (185) - [INFO] : [风控] 强制延迟0.71秒(如需关闭,请到config.py修改force_delay_range字段)

@lsx626
Copy link
Author

lsx626 commented Nov 21, 2023

我在pycharm试图调试时,(未更改任何代码)运行main.py,之前的报错消失了。而我在重新给机器人发送消息时,pycharm控制台显示:
[2023-11-22 01:53:08.746] _client.py (1013) - [INFO] : HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 429 Too Many Requests"
[2023-11-22 01:53:08.748] _base_client.py (927) - [INFO] : Retrying request to /chat/completions in 0.868332 seconds
[2023-11-22 01:53:09.692] _client.py (1013) - [INFO] : HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 429 Too Many Requests"
[2023-11-22 01:53:09.693] _base_client.py (927) - [INFO] : Retrying request to /chat/completions in 1.594417 seconds
[2023-11-22 01:53:11.368] _client.py (1013) - [INFO] : HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 429 Too Many Requests"

若是不在pycharm运行而是直接运行bat的话,仍然是err:BaseClient.build_request() got an unexpected keyword argument 'timeout'

@RockChinQ
Copy link
Owner

#606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug? Bug或Bug修复相关 IM: YiriMirai mirai-api-http 协议适配器相关 重复 已存在相同的issue或PR
Projects
None yet
Development

No branches or pull requests

2 participants