NumberSir / nonebot_plugin_arktools

基于 OneBot 适配器的 NoneBot2 明日方舟小工具箱插件
MIT License
68 stars 15 forks source link

更新素材库报错 #44

Closed Ra1n-qwq closed 1 year ago

Ra1n-qwq commented 1 year ago

使用命令 "更新方舟素材" 报错

05-19 18:08:42 [INFO] nonebot_plugin_arktools |         - Arknights-Image downloaded: skin/char_308_swire_2b.png
05-19 18:08:42 [INFO] nonebot_plugin_arktools |         - Arknights-Image downloaded: skin/char_416_zumama_2b.png
05-19 18:08:42 [INFO] nonebot_plugin_arktools |         - Arknights-Image downloaded: skin/char_4048_doroth_2b.png
05-19 18:08:44 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_arktools.src.utils) running complete
05-19 18:08:44 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_arktools.src.utils) failed.
ConnectionResetError: [Errno 104] Connection reset by peer

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

Traceback (most recent call last):
  File ".local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 8, in map_exceptions
    yield
  File ".local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 76, in start_tls
    raise exc
  File ".local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 67, in start_tls
    ssl_stream = await anyio.streams.tls.TLSStream.wrap(
  File "/usr/local/lib/python3.10/site-packages/anyio/streams/tls.py", line 122, in wrap
    await wrapper._call_sslobject_method(ssl_object.do_handshake)
  File "/usr/local/lib/python3.10/site-packages/anyio/streams/tls.py", line 137, in _call_sslobject_method
    data = await self.transport_stream.receive()
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 1274, in receive
    raise self._protocol.exception
anyio.BrokenResourceError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File ".local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File ".local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
    raise exc
  File ".local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
    response = await connection.handle_async_request(request)
  File ".local/lib/python3.10/site-packages/httpcore/_async/http_proxy.py", line 286, in handle_async_request
    stream = await stream.start_tls(**kwargs)
  File ".local/lib/python3.10/site-packages/httpcore/backends/asyncio.py", line 64, in start_tls
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File ".local/lib/python3.10/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
    raise to_exc(exc)
httpcore.ConnectError

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

Traceback (most recent call last):
  File ".local/lib/python3.10/site-packages/nonebot_plugin_arktools/src/utils/__init__.py", line 25, in _
    await ArknightsGameImage(client).download_files()
  File ".local/lib/python3.10/site-packages/nonebot_plugin_arktools/src/utils/update.py", line 207, in download_files
    await asyncio.gather(*tasks)
  File ".local/lib/python3.10/site-packages/nonebot_plugin_arktools/src/utils/update.py", line 218, in save
    content = (await self._client.get(quote(url, safe="/:"), timeout=100, follow_redirects=True)).content
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1754, in get
    return await self.request(
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
    response = await self._send_single_request(request)
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 1719, in _send_single_request
    response = await transport.handle_async_request(request)
  File ".local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File ".local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/nb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/nb_cli/commands/main.py", line 30, in run
    run_bot(file, app)
  File "/usr/local/lib/python3.10/site-packages/nb_cli/handlers/deploy.py", line 25, in run_bot
    nonebot.run(app=f"{module_name}:{app}")
  File ".local/lib/python3.10/site-packages/nonebot/__init__.py", line 273, in run
    get_driver().run(*args, **kwargs)
  File ".local/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 187, in run
    uvicorn.run(
  File ".local/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run
    server.run()
  File ".local/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File ".local/lib/python3.10/site-packages/nonebot/message.py", line 141, in _check_matcher
    await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)
> File ".local/lib/python3.10/site-packages/nonebot/message.py", line 187, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File ".local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File ".local/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run
    await handler(
  File ".local/lib/python3.10/site-packages/nonebot/dependencies/__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File ".local/lib/python3.10/site-packages/nonebot_plugin_arktools/src/utils/__init__.py", line 22, in _
    async with httpx.AsyncClient() as client:
  File ".local/lib/python3.10/site-packages/httpx/_client.py", line 2003, in __aexit__
    await proxy.__aexit__(exc_type, exc_value, traceback)
  File ".local/lib/python3.10/site-packages/httpx/_transports/default.py", line 332, in __aexit__
    await self._pool.__aexit__(exc_type, exc_value, traceback)
  File ".local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 326, in __aexit__
    await self.aclose()
  File ".local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 312, in aclose
    raise RuntimeError(
RuntimeError: The connection pool was closed while 557 HTTP requests/responses were still in-flight.
Ra1n-qwq commented 1 year ago

从头开始更新就会出现这种情况。怀疑是短时间内请求次数过多,没有做报错&重试处理,限制下请求频率可能可以解决。

guguguy114 commented 1 year ago

启动插件时报错 `Traceback (most recent call last): File "D:\PRJ\pythonPRJ\GuguguyBot\Guguguy\gocqhttp\Guguguy\bot.py", line 22, in nonebot.run() File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot__init__.py", line 309, in run get_driver().run(*args, *kwargs) File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot\drivers\fastapi.py", line 198, in run uvicorn.run( File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\uvicorn\main.py", line 578, in run server.run() File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Program Files\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete self.run_forever() File "C:\Program Files\Python310\lib\asyncio\windows_events.py", line 321, in run_forever super().run_forever() File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 600, in run_forever self._run_once() File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 1896, in _run_once handle._run() File "C:\Program Files\Python310\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, self._args)

File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot\internal\driver\driver.py", line 152, in _run_hook await asyncio.gather(*coros) File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot\utils.py", line 158, in run_coro_with_catch return await coro File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot\dependencies__init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot_plugin_arktools\src\utils\database.py", line 433, in _init_db await ArknightsDB.init_db() File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot_plugin_arktools\src\utils\database.py", line 56, in init_db await ArknightsDB.init_data() File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot_plugin_arktools\src\utils\database.py", line 70, in init_data await ArknightsDB._init_building_buff(force) File "C:\Users\10953\AppData\Roaming\Python\Python310\site-packages\nonebot_plugin_arktools\src\utils\database.py", line 94, in _init_building_buff data = json.loads(data) File "C:\Program Files\Python310\lib\json\init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)`

另外打开json文件时没有内容,只有一句“invalid input!”

guguguy114 commented 1 year ago

所有json都无法获取到数据

NumberSir commented 1 year ago

未复现,请检查以下可能的导致报错的原因:

Ra1n-qwq commented 1 year ago

那有可能就是代理的问题了,服务器挂了代理。