GraiaProject / Ariadne

一个优雅且完备的 Python QQ 自动化框架,基于 Mirai API HTTP v2。 Powered by Graia Project.
https://graia.cn/ariadne
GNU Affero General Public License v3.0
751 stars 45 forks source link

ValueError: Invalid stage transition: finished -> blocking #209

Closed hsn8086 closed 1 year ago

hsn8086 commented 1 year ago

问题

在启动时报错.

已多次检查mirai以及mirai-api-http的配置,并使用不同版本的py尝试运行,且更新了框架,仍无法解决问题. 也无法在日志中找出问题的关键. 看了closed的issue无果(如果是我看漏了拜托指个路)

(曾经可以在此环境下运行)

使用环境:

日志/截图 日志:

Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。

C:\Users\Administrator\Desktop\QMGR\bot>python bot.py

C:\Users\Administrator\Desktop\QMGR\bot>C:\Users\Administrator\AppData\Local\Pro
grams\Python\Python39\python bot.py
2023-01-03 20:50:06.938 | INFO     | launart.manager:launch_blocking:480 - Start
ing launart main task...
2023-01-03 20:50:06.938 | INFO     | launart.manager:launch:333 - Launching 5 co
mponents as async task...
2023-01-03 20:50:07.000 | INFO     | graia.ariadne.service:base_telemetry:144 -

    _         _           _
   / \   _ __(_) __ _  __| |_ __   ___
  / _ \ | '__| |/ _` |/ _` | '_ \ / _ \
 / ___ \| |  | | (_| | (_| | | | |  __/
/_/   \_\_|  |_|\__,_|\__,_|_| |_|\___|

graia-amnesia: 0.7.1
graia-ariadne: 0.10.2
graia-broadcast: 0.19.1
launart: 0.6.2
statv: 0.3.2
2023-01-03 20:50:07.000 | INFO     | launart.manager:_launchable_task_done_callback:68 - [elizabeth.connection.3520295800.http_client_connection] completed.
2023-01-03 20:50:07.000 | SUCCESS  | launart.manager:launch:385 - Layer #1:[cache.client/memcache, http.client/aiohttp] preparation completed.
2023-01-03 20:50:07.000 | SUCCESS  | launart.manager:launch:385 - Layer #3:[elizabeth.service] preparation completed.
2023-01-03 20:50:07.000 | INFO     | launart.manager:launch:390 - All components prepared, start blocking phase.
2023-01-03 20:50:07.000 | ERROR    | launart.manager:_launchable_task_done_callback:43 - [elizabeth.connection.3520295800.websocket_client_connection] raised aexception.
Traceback (most recent call last):

> File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\graia\ariadne\connection\ws.py", line 178, in launch
    async with self.stage("blocking"):
               │    └ <function Launchable.stage at 0x00000061039B31F0>
               └ <WebsocketClientConnection <ConnectionStatus connected=False alive=False verified=False stage=finished> with 2 callbacks>

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 181, in __aenter__
    return await self.gen.__anext__()
                 │    │   └ <slot wrapper '__anext__' of 'async_generator' objects>
                 │    └ <async_generator object Launchable.stage at 0x0000006104B8E550>
                 └ <contextlib._AsyncGeneratorContextManager object at 0x0000006104D86790>

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\launart\component.py", line 154, in stage
    self.status.stage = "blocking"
    │    │      └ <statv.Stats object at 0x00000061039CB1F0>
    │    └ <ConnectionStatus connected=False alive=False verified=False stage=finished>
    └ <WebsocketClientConnection <ConnectionStatus connected=False alive=False verified=False stage=finished> with 2 callbacks>

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\statv.py", line 67, in __set__
    value = self._validator(self, past_value, value)
            │    │          │     │           └ 'blocking'
            │    │          │     └ 'finished'
            │    │          └ <statv.Stats object at 0x00000061039CB1F0>
            │    └ <function LaunchableStatus._ at 0x00000061039C0A60>
            └ <statv.Stats object at 0x00000061039CB1F0>

  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\launart\component.py", line 79, in _
    raise ValueError(f"Invalid stage transition: {past} -> {current}")

ValueError: Invalid stage transition: finished -> blocking

程序:

from graia.ariadne.event.message import GroupMessage
from graia.ariadne.app import Ariadne
from graia.ariadne.entry import config
from graia.ariadne.message.chain import MessageChain
from graia.ariadne.model import Group

app = Ariadne(
    config(
        verify_key="ServiceVerifyKey",  # 填入 VerifyKey
        account='原本是qq号',  # 你的机器人的 qq 号
    ),
)

@app.broadcast.receiver(GroupMessage)
async def friend_message_listener(app: Ariadne, msg: MessageChain, group: Group):
    if group.id == '原本是群号':
        await app.send_message(group, "test")

app.launch_blocking()

配置文件:

# file: "MCL/config/net.mamoe.mirai-api-http/setting.yml"
## 配置文件中的值,全为默认值

## 启用的 adapter, 内置有 http, ws, reverse-ws, webhook
adapters:
  - http
  - ws

## 是否开启认证流程, 若为 true 则建立连接时需要验证 verifyKey
enableVerify: true
verifyKey: ServiceVerifyKey

## 开启一些调试信息
debug: false

## 是否开启单 session 模式, 不建议开启
singleMode: false

## 历史消息的缓存大小
## 同时,也是 http adapter 的消息队列容量
cacheSize: 4096

## adapter 的单独配置,键名与 adapters 项配置相同
## 注意: 如果 mirai 读取配置时出错可以尝试删除并重新写入
adapterSettings:
  ## HTTP 服务的主机, 端口和跨域设置
  http:
    host: localhost
    port: 8080
    cors: ["*"]

  ## Websocket 服务的主机, 端口和事件同步ID设置
  ws:
    host: localhost
    port: 8080
    reservedSyncId: -1
BlueGlassBlock commented 1 year ago

已经确认问题根源,今晚应该可以修复。

BlueGlassBlock commented 1 year ago

Fixed in v0.10.3