Soulter/AstrBot

[Bug]DALLE画图无法使用,报错failed to render image via AstrBot API

Closed this issue · 4 comments

发生了什么

使用画图功能时提示
2024-09-07 20:37:08.556| INFO |MainThread|astrbot.reply_msg|qq_aiocqhttp.py:179 - 330132515 <- 请帮我画一张福建美食的图片 2024-09-07 20:37:08.843| ERROR |MainThread|astrbot.render|renderer.py:20 - Failed to render image via AstrBot API: Cannot connect to host t2i.soulter.top:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1007)')]. Falling back to local rendering.

如何复现?

正常使用画图情况下均可复现,包括Ubuntu服务器(Docker),Windows本地部署

AstrBot 版本与部署方式

均为最新版,Windows和Docker均尝试过

操作系统

Windows

额外信息

` 2024-09-07 20:37:08.556| INFO |MainThread|astrbot.reply_msg|qq_aiocqhttp.py:179 - 330132515 <- 请帮我画一张福建美食的图片
2024-09-07 20:37:08.843| ERROR |MainThread|astrbot.render|renderer.py:20 - Failed to render image via AstrBot API: Cannot connect to host t2i.soulter.top:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1007)')]. Falling back to local rendering.
Task exception was never retrieved
future: <Task finished name='Task-25' coro=<CQHttp._handle_event_with_response() done, defined at /usr/local/lib/python3.10/site-packages/aiocqhttp/init.py:604> exception=AttributeError("'NoneType' object has no attribute 'getsize'")>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1080, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs, sock=sock)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1103, in create_connection
transport, protocol = await self._create_connection_transport(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1133, in _create_connection_transport
await waiter
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1007)

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

Traceback (most recent call last):
File "/AstrBot/util/t2i/renderer.py", line 18, in render
return await self.context.render(text, return_url=return_url)
File "/AstrBot/util/t2i/context.py", line 11, in render
return await self._strategy.render(text, return_url)
File "/AstrBot/util/t2i/strategies/network_strategy.py", line 41, in render
async with session.post(f"{self.BASE_RENDER_URL}/generate", json=post_data) as resp:
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1353, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 657, in _request
conn = await self._connector.connect(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 564, in connect
proto = await self._create_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 975, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1350, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1319, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1082, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host t2i.soulter.top:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1007)')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiocqhttp/init.py", line 606, in _handle_event_with_response
response = await self._handle_event(payload)
File "/usr/local/lib/python3.10/site-packages/aiocqhttp/init.py", line 599, in _handle_event
filter(lambda r: r is not None, await
File "/usr/local/lib/python3.10/site-packages/aiocqhttp/bus.py", line 60, in emit
results += await run_async_funcs(self._subscribers[event], *args,
File "/usr/local/lib/python3.10/site-packages/aiocqhttp/utils.py", line 40, in run_async_funcs
results += await asyncio.gather(*coros)
File "/AstrBot/model/platform/qq_aiocqhttp.py", line 94, in private
await self.handle_msg(abm)
File "/AstrBot/model/platform/qq_aiocqhttp.py", line 163, in handle_msg
await self.reply_msg(message, message_result.result_message, message_result.use_t2i)
File "/AstrBot/model/platform/qq_aiocqhttp.py", line 189, in reply_msg
rendered_images = await self.convert_to_t2i_chain(res)
File "/AstrBot/model/platform/init.py", line 77, in convert_to_t2i_chain
p = await self.context.image_renderer.render(plain_str, return_url=True)
File "/AstrBot/util/t2i/renderer.py", line 22, in render
return await self.context.render(text)
File "/AstrBot/util/t2i/context.py", line 11, in render
return await self._strategy.render(text, return_url)
File "/AstrBot/util/t2i/strategies/local_strategy.py", line 102, in render
if font.getsize(line)[0] > image_width:
AttributeError: 'NoneType' object has no attribute 'getsize'`

你愿意提交 PR 吗?

  • 是的,我愿意提交 PR!

Code of Conduct

image

看到关键词SSL证书验证错误,所以也尝试过已经关闭的issue中的方法:https://github.com/Soulter/AstrBot/issues/196 尝试了 删掉 xxxx=ssl.CERT_NONE 一行

但该问题依然出现

已修复,是 t2i.soulter.top 域名证书过期导致的。

已经修复,同时注意到新版pillow不支持getsize了,可以全局换成getbbox解决,或使用旧版pillow9

已经修复,同时注意到新版pillow不支持getsize了,可以全局换成getbbox解决,或使用旧版pillow9

好的,感谢提供解决办法。