AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]识别图片提示未配置代理

Open yydsxiaobai opened this issue 9 months ago • 6 comments

What happened / 发生了什么

群里有人发送图片的时候机器人提示 AstrBot 请求失败。 错误类型: APIConnectionError 错误信息: Connection error.

请在平台日志查看和分享错误详情。

Reproduce / 如何复现?

设置好图片理解模型后群里发送图片

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

docker部署,astrbot版本4.1.50

OS

Linux

Logs / 报错日志

群里有人发图片就会提示未配置代理

[13:43:37] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot_plugin_immersive_control - on_llm_request [13:43:37] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot_plugin_stealer - _inject_emotion_instruction [13:43:37] [Plug] [DBUG] [astrbot_plugin_stealer.main:998]: [Stealer] LLM模式已启用,跳过提示词注入,将使用轻量模型分析 [13:43:37] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req [13:43:37] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot-web-searcher - edit_web_search_tools [13:43:37] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING [13:43:46] [Core] [ERRO] [v4.15.0] [utils.network_utils:80]: [OpenAI] 网络连接失败 (APIConnectionError),未配置代理。错误: Connection error. [13:43:46] [Core] [ERRO] [v4.15.0] [core.astr_agent_run_util:136]: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions yield File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 394, in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request raise exc from None File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request response = await connection.handle_async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request return await self._connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 136, in handle_async_request raise exc File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 106, in handle_async_request ) = await self._receive_response_headers(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 177, in _receive_response_headers event = await self._receive_event(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 217, in _receive_event data = await self._network_stream.read( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 32, in read with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/usr/local/lib/python3.12/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ReadError

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

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1604, in request response = await self._client.send( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1629, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1657, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1730, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 393, in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/contextlib.py", line 158, in exit self.gen.throw(value) File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadError

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

Traceback (most recent call last): File "/AstrBot/astrbot/core/astr_agent_run_util.py", line 52, in run_agent async for resp in agent_runner.step(): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 210, in step async for llm_response in self._iter_llm_responses(): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 184, in _iter_llm_responses yield await self.provider.text_chat(**payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 521, in text_chat ) = await self._handle_api_error( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 474, in _handle_api_error raise e File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 510, in text_chat llm_response = await self._query(payloads, func_tool) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 127, in _query completion = await self.client.chat.completions.create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/resources/chat/completions/completions.py", line 2678, in create return await self._post( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1884, in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/openai/_base_client.py", line 1636, in request raise APIConnectionError(request=request) from err openai.APIConnectionError: Connection error.

[13:43:46] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> spectrecore - on_llm_resp [13:43:46] [Plug] [DBUG] [astrbot_plugin_spectrecore.main:81]: 收到大模型回复喵: LLMResponse(role='err', result_chain=None, tools_call_args=[], tools_call_name=[], tools_call_ids=[], tools_call_extra_content={}, reasoning_content='', reasoning_signature=None, raw_completion=None, _completion_text='\n\nAstrBot 请求失败。\n错误类型: APIConnectionError\n错误信息: Connection error.\n\n请在平台日志查看和分享错误详情。\n', is_chunk=False, id=None, usage=None) [13:43:46] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot_plugin_livingmemory - handle_memory_reflection [13:43:46] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot - record_llm_resp_to_ltm [13:43:46] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_stealer - _prepare_emoji_response [13:43:46] [Plug] [DBUG] [astrbot_plugin_stealer.main:1056]: [Stealer] 非 LLM 回复,跳过表情包处理 [13:43:46] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_outputpro - on_decorating_result [13:43:48] [Plug] [DBUG] [core.pipeline:103]: 命中报错关键词 请求失败,转发成功,原消息替换为
[13:43:48] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> spectrecore - on_decorating_result [13:43:48] [Core] [INFO] [respond.stage:168]: Prepare to send -    /3066841974:
[13:43:48] [Core] [INFO] [respond.stage:199]: 消息为空,跳过发送阶段 [13:43:48] [Core] [DBUG] [pipeline.scheduler:88]: pipeline 执行完毕。 [13:46:19] [Plug] [INFO] [astrbot_plugin_stealer.main:892]: 开始执行raw目录清理任务 [13:46:19] [Plug] [DBUG] [astrbot_plugin_stealer.event_handler:465]: 开始清理raw目录: /AstrBot/data/plugin_data/astrbot_plugin_stealer/raw [13:46:19] [Plug] [INFO] [astrbot_plugin_stealer.event_handler:470]: raw目录已为空: /AstrBot/data/plugin_data/astrbot_plugin_stealer/raw [13:46:19] [Plug] [INFO] [astrbot_plugin_stealer.event_handler:496]: 清理完成,总计删除 0 个文件 [13:46:19] [Plug] [INFO] [astrbot_plugin_stealer.main:895]: raw目录清理任务完成

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [ ] Yes!

Code of Conduct

yydsxiaobai avatar Feb 11 '26 13:02 yydsxiaobai

Hi @yydsxiaobai! I'm Dosu and I’m helping the AstrBot team.

你的报错“未配置代理”说明 AstrBot 在调用 OpenAI API 进行图片识别时,检测不到有效的 HTTP/HTTPS 代理配置,导致网络请求失败(APIConnectionError)参考。

常见原因和排查建议:

1. 代理配置方式

  • AstrBot 支持两种代理配置:一是在 provider 配置中填写 proxy 字段(推荐),二是设置容器环境变量 HTTP_PROXY/HTTPS_PROXY(会被 provider 配置覆盖)参考。
  • provider 级别的 proxy 字段只影响该 provider 的 API 请求,不影响 Docker 内部通信。

2. Docker 部署注意事项

  • 仅在主机设置代理无效,必须确保 Docker 容器内也设置了代理环境变量,或在 AstrBot 控制台/配置文件的 provider 里填写 proxy 字段(如 http://你的代理地址:端口)。
  • 如果你在中国大陆,访问 OpenAI 等国外 API 必须配置代理,否则会出现类似错误。

3. 代理地址正确性

  • 不要把反向代理(如 Netflix 反代)地址填到 HTTP 代理配置里,必须是标准的 HTTP/HTTPS 代理(如 Clash、V2Ray、Shadowsocks 提供的端口)参考。
  • 检查代理是否可用,防火墙或云安全组是否放行。

4. 其他常见问题

  • DNS 解析失败、网络不通、代理配置错误都会导致类似报错参考。
  • 某些旧版本 AstrBot 只认配置文件里的代理,建议升级到最新版获得更好的代理支持和日志参考。

操作建议

  1. 推荐在 AstrBot 控制台或配置文件的 OpenAI provider 里填写 proxy 字段(如 http://host.docker.internal:7890)。
  2. 或者在 docker-compose.yml 的环境变量里加上 HTTP_PROXY 和 HTTPS_PROXY。
  3. 检查代理服务是否正常,代理端口是否开放。
  4. 避免将反向代理地址误填为 HTTP 代理。

如需进一步定位,可贴出你的 provider 配置和 docker-compose 相关环境变量。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about AstrBot with Dosu Add Dosu to your team

dosubot[bot] avatar Feb 11 '26 14:02 dosubot[bot]

我看看

tooplick avatar Feb 12 '26 07:02 tooplick

你好呀可以看一下相关的设置吗,如:

Image

tooplick avatar Feb 12 '26 08:02 tooplick

建议配置代理之后再次尝试,观察是否报错,然后确定是否是网络原因还是bot方面的问题。目前因为不清楚你具体使用的图片解析提供商,所以无法进一步定位问题。 日志中未配置代理并非报错点,而是单纯描述当时的运行状态,即不走代理。

zouyonghe avatar Feb 12 '26 12:02 zouyonghe

如果你的Linux服务器在国内的话,使用国外的API用来当做图片转述模型,在未配置代理服务器的情况下是会有网络问题的,就会报错

tooplick avatar Feb 12 '26 13:02 tooplick

问题依然存在的话请再次开启此issue

zouyonghe avatar Feb 13 '26 12:02 zouyonghe