Bug: 出现异常 http连接无法使用
laiyoi opened this issue · 1 comments
laiyoi commented
操作系统
Windows
Python 版本
3.9.0
NoneBot 版本
2.1.3
适配器
onebot v11 2.3.1
协议端
llonebot 2.3.0
描述问题
可以收到消息不能发送,
经测试是site-packages\nonebot\adapters\onebot\v11\adapter.py
中148行elif isinstance(self.driver, HTTPClientMixin):
鉴定为假导致的
如果.env.pord
中DRIVER=~fastapi
换为DRIVER=~httpx
则根本没有02-04 02:56:34 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:11451 (Press CTRL+C to quit)
这一行
复现步骤
启动ntqq,前端上报地址为http://127.0.0.1:11451/onebot/v11/
,监听端口为5141
.env.pord
中ONEBOT_API_ROOTS={"3556822808": "http://127.0.0.1:5141/"}
浏览器中访问http://127.0.0.1:5141/
看到llonebot已启动
向bot发送echo 1
期望的结果
回复1
截图或日志
(nb) PS E:\nb\plugin_test> nb run
02-04 02:56:33 [SUCCESS] nonebot | NoneBot is initializing...
02-04 02:56:33 [INFO] nonebot | Current Env: prod
02-04 02:56:33 [DEBUG] nonebot | Loaded Config: {'driver': '~fastapi', 'host': IPv4Address('127.0.0.1'), 'port': 11451, 'log_level': 'DEBUG', 'api_timeout': 30.0, 'superusers': {'3596094466'}, 'nickname': {'池烟
然', '天真有邪'}, 'command_start': {'', '/'}, 'command_sep': {'.', ' '}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'jinyan_group': ['563484241'], 'jinyan_max_count': 3, 'jinyan_max_time': 20, 'onebot_api_roots': {'3556822808': 'http://127.0.0.1:5141/'}}
02-04 02:56:33 [DEBUG] nonebot | Succeeded to load adapter "OneBot V11"
02-04 02:56:33 [SUCCESS] nonebot | Succeeded to load plugin "echo" from "nonebot.plugins.echo"
02-04 02:56:34 [SUCCESS] nonebot | Succeeded to load plugin "nonebot-plugin-jinyan" from "plugins.nonebot-plugin-jinyan"
02-04 02:56:34 [SUCCESS] nonebot | Running NoneBot...
02-04 02:56:34 [DEBUG] nonebot | Loaded adapters: OneBot V11
02-04 02:56:34 [INFO] uvicorn | Started server process [14576]
02-04 02:56:34 [INFO] uvicorn | Waiting for application startup.
02-04 02:56:34 [INFO] uvicorn | Application startup complete.
02-04 02:56:34 [INFO] uvicorn | Uvicorn running on http://127.0.0.1:11451 (Press CTRL+C to quit)
02-04 02:56:44 [INFO] nonebot | OneBot V11 | Bot 3556822808 connected
02-04 02:56:44 [INFO] uvicorn | 127.0.0.1:9971 - "POST /onebot/v11/ HTTP/1.1" 204
02-04 02:56:44 [SUCCESS] nonebot | OneBot V11 3556822808 | [message.private.friend]: Message 7331451640639909361 from 3596094466 'echo 1'
02-04 02:56:44 [DEBUG] nonebot | Checking for matchers in priority 1...
02-04 02:56:44 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot.plugins.echo, lineno=17)
02-04 02:56:44 [DEBUG] nonebot | Running Matcher(type='message', module=nonebot.plugins.echo, lineno=17)
02-04 02:56:44 [DEBUG] nonebot | Running handler Dependent(call=handle_echo)
02-04 02:56:44 [DEBUG] nonebot | OneBot V11 | Calling API send_msg
02-04 02:56:44 [INFO] nonebot | Matcher(type='message', module=nonebot.plugins.echo, lineno=17) running complete
02-04 02:56:44 [ERROR] nonebot | Running Matcher(type='message', module=nonebot.plugins.echo, lineno=17) failed.
Traceback (most recent call last):
File "E:\nb\plugin_test\bot.py", line 17, in <module>
nonebot.run()
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\__init__.py", line 331, in run
get_driver().run(*args, **kwargs)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\drivers\fastapi.py", line 189, in run
uvicorn.run(
File "E:\anaconda\envs\nb\lib\site-packages\uvicorn\main.py", line 587, in run
server.run()
File "E:\anaconda\envs\nb\lib\site-packages\uvicorn\server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
File "E:\anaconda\envs\nb\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "E:\anaconda\envs\nb\lib\asyncio\base_events.py", line 629, in run_until_complete
self.run_forever()
File "E:\anaconda\envs\nb\lib\asyncio\windows_events.py", line 316, in run_forever
super().run_forever()
File "E:\anaconda\envs\nb\lib\asyncio\base_events.py", line 596, in run_forever
self._run_once()
File "E:\anaconda\envs\nb\lib\asyncio\base_events.py", line 1890, in _run_once
handle._run()
File "E:\anaconda\envs\nb\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\message.py", line 476, in check_and_run_matcher
await _run_matcher(
> File "E:\anaconda\envs\nb\lib\site-packages\nonebot\message.py", line 428, in _run_matcher
await matcher.run(bot, event, state, stack, dependency_cache)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\internal\matcher\matcher.py", line 846, in run
await self.simple_run(bot, event, state, stack, dependency_cache)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\internal\matcher\matcher.py", line 821, in simple_run
await handler(
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\dependencies\__init__.py", line 113, in __call__
return await cast(Callable[..., Awaitable[R]], self.call)(**values)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\plugins\echo.py", line 22, in handle_echo
await echo.send(message=message)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\internal\matcher\matcher.py", line 554, in send
return await bot.send(event=event, message=_message, **kwargs)
return await self.__class__.send_handler(self, event, message, **kwargs)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\adapters\onebot\v11\bot.py", line 178, in send
return await bot.send_msg(**params)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\internal\adapter\bot.py", line 123, in call_api
raise exception
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\internal\adapter\bot.py", line 98, in call_api
result = await self.adapter._call_api(self, api, **data)
File "E:\anaconda\envs\nb\lib\site-packages\nonebot\adapters\onebot\v11\adapter.py", line 186, in _call_api
raise ApiNotAvailable
nonebot.adapters.onebot.v11.exception.ApiNotAvailable: ApiNotAvailable()
MingxuanGame commented