SAGIRI-kawaii / sagiri-bot

基于Graia Ariadne和Mirai的QQ机器人 SAGIRI-BOT
GNU Affero General Public License v3.0
696 stars 83 forks source link

[Bug Report] 当使用 SQLite3 时 Bot无法启动 #162

Closed sxjeru closed 2 years ago

sxjeru commented 2 years ago

环境信息

系统版本: Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-90-generic x86_64) 源码版本: v2.1.7 其他信息: mirai-api-http-v1.12.0

SQLite3 问题日志请见下方回复,此处网络问题已解决。

问题描述

已更换不同版本尝试多次。

mah的“setting.yml”中设置如下(部分):

host: "0.0.0.0"    # localhost 也尝试过
port: 12580    #多次尝试更换端口

"config.yaml"中设置如下:

miraiHost: http://localhost:12580

日志

(截取报错部分)

[2021-12-11 21:54:24,315][INFO]: initializing app...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 12580)

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

Traceback (most recent call last):
  File "main.py", line 71, in <module>
    core.launch()
  File "/root/sagiri-bot-2.1.7/SAGIRIBOT/Core/AppCore.py", line 107, in launch
    self.__app.launch_blocking()
  File "/usr/local/lib/python3.8/dist-packages/graia/application/__init__.py", line 1613, in launch_blocking
    loop.run_until_complete(self.initialize())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.8/dist-packages/graia/application/__init__.py", line 1503, in initialize
    await self.authenticate()
  File "/usr/local/lib/python3.8/dist-packages/graia/application/utilles.py", line 27, in wrapper
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/graia/application/__init__.py", line 301, in authenticate
    async with self.session.post(
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host localhost:12580 ssl:default [Connect call failed ('127.0.0.1', 12580)]

感谢作者付出,star 已给~

nullqwertyuiop commented 2 years ago

监听 IP 换 127.0.0.1 试试?

sxjeru commented 2 years ago

感谢回复。两边配置文件都尝试改为 127.0.0.1 ,可惜问题依旧,报错相同。

nullqwertyuiop commented 2 years ago

怪怪的 我看看我的配置

nullqwertyuiop commented 2 years ago

mah

host: 127.0.0.1
port: 8765
enableWebsocket: true

sagiri

miraiHost: http://127.0.0.1:8765

怪欸,我debian可以正常跑()

sxjeru commented 2 years ago

不过咱这边的 Mirai 是跑在 docker 上的,不知道是否有关联。

nullqwertyuiop commented 2 years ago

有可能

nullqwertyuiop commented 2 years ago

我是用mcl跑的

sxjeru commented 2 years ago

放到本地测试,网络问题不再报错。不过运行到后面还是无法启动。

[2021-12-11 23:35:55,116][INFO]: --- setting end ---
[2021-12-11 23:35:55,116][INFO]: application has been initialized, used 0.0495s
2021-12-11 23:35:55.123 | ERROR    | SAGIRIBOT.Core.AppCore:bot_launch_init:174 - Traceback (most recent call last):
  File "/root/sagiri-bot-2.1.7/SAGIRIBOT/Core/AppCore.py", line 131, in bot_launch_init
    await orm.create_all()
  File "/root/sagiri-bot-2.1.7/SAGIRIBOT/ORM/AsyncORM.py", line 96, in create_all
    async with self.engine.begin() as conn:
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/base.py", line 60, in __aenter__
    return await self.start(is_ctxmanager=True)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/engine.py", line 586, in start
    await self.conn.start(is_ctxmanager=is_ctxmanager)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/ext/asyncio/engine.py", line 131, in start
    await (greenlet_spawn(self.sync_engine.connect))
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/util/_concurrency_py3k.py", line 136, in greenlet_spawn
    result = context.switch(value)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/future/engine.py", line 406, in connect
    return super(Engine, self).connect()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3204, in connect
    return self._connection_cls(self, close_with_result=close_with_result)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 96, in __init__
    else engine.raw_connection()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3283, in raw_connection
    return self._wrap_pool_connect(self.pool.connect, _connection)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/base.py", line 3250, in _wrap_pool_connect
    return fn()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 310, in connect
    return _ConnectionFairy._checkout(self)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 868, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 476, in checkout
    rec = pool._do_get()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/impl.py", line 256, in _do_get
    return self._create_connection()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 256, in _create_connection
    return _ConnectionRecord(self)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 371, in __init__
    self.__connect()
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/pool/base.py", line 677, in __connect
    pool.dispatch.connect.for_modify(
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/event/attr.py", line 329, in _exec_w_sync_on_first_run
    self(*args, **kw)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/event/attr.py", line 343, in __call__
    fn(*args, **kw)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/engine/create.py", line 670, in on_connect
    do_on_connect(dbapi_connection)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 545, in connect
    fn(conn)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 528, in set_regexp
    dbapi_connection.create_function(
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 189, in create_function
    self._handle_exception(error)
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 229, in _handle_exception
    raise error
  File "/usr/local/lib/python3.8/dist-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 187, in create_function
    self.await_(self._connection.create_function(*args, **kw))
AttributeError: 'Connection' object has no attribute 'create_function'

[2021-12-11 23:35:55,125][INFO]: websocket daemon: websocket connection starting...
[2021-12-11 23:35:55,202][INFO]: application shutdowned.
nullqwertyuiop commented 2 years ago

没用过 SQLite,问问仓库作者?

sxjeru commented 2 years ago

用的是 sqlite3 ,全部都在系统环境运行,没用 docker 了。

还是感谢帮助了。

nullqwertyuiop commented 2 years ago

试试 MySQL?(×)

nullqwertyuiop commented 2 years ago

虽然现阶段可能有些千奇百怪的 bug(×)

nullqwertyuiop commented 2 years ago

Stackoverflow 上面找到了个可能的方法,但是没用过 SQLite 所以不敢乱改源码(

sxjeru commented 2 years ago

config.yaml 中换用 MySQL 后可正常启动。 alembic.ini 中可使用 Sqlite 。

nullqwertyuiop commented 2 years ago

很奇怪,我这里使用 SQLite3 时可以正常运行。

SAGIRI-kawaii commented 2 years ago

旧版本不再支持,请尝试使用SAGIRI-BOT-Ariadne