GraiaProject / Application

一个设计精巧, 协议实现完备的, 基于 mirai-api-http 的即时聊天软件自动化框架.
https://graia-document.vercel.app/
GNU Affero General Public License v3.0
438 stars 63 forks source link

握手失败,是否因为localhost地址和端口相关的原因 #164

Closed bowielab76 closed 2 years ago

bowielab76 commented 3 years ago

似乎是和localhost之间的通讯出现了问题,不确定是否是因为settings.yml和bot.py之间的设置有误。

复现步骤: 该 BUG 会在进行以下操作后出现:

  1. My settings for http are:

    adapters:
    - http
    debug: false
    enableVerify: true
    verifyKey: hYR4ccgwTu #randomised for privacy purposes
    singleMode: false
    cacheSize: 4096
    adapterSettings: {
    http:
    host: localhost
    port: 8080
    cors: [*]
    }
  2. My bot.py settings:

    app = GraiaMiraiApplication(
    broadcast=bcc,
    connect_info=Session(
        host="http://localhost:8080", 
        authKey="hYR4ccgwTu",
        account=(my bot account), 
        websocket=True 
    )
    )

发生错误的代码

Traceback (most recent call last):
  File "/Users/username/Downloads/bot.py", line 29, in <module>
    app.launch_blocking()
  File "/usr/local/lib/python3.9/site-packages/graia/application/__init__.py", line 1613, in launch_blocking
    loop.run_until_complete(self.initialize())
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.9/site-packages/graia/application/__init__.py", line 1503, in initialize
    await self.authenticate()
  File "/usr/local/lib/python3.9/site-packages/graia/application/utilles.py", line 27, in wrapper
    return await func(self, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/graia/application/__init__.py", line 304, in authenticate
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1000, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('http://localhost:8080/auth')

控制台日志输出截图: image image

运行环境:

SiriusNEO commented 3 years ago

https://github.com/project-mirai/mirai-api-http/issues/435

HowcanoeWang commented 3 years ago

遇到了同样的问题,mcl自动登陆QQ接受消息ok,关闭mcl后直接使用python bot.py运行会得到https://github.com/project-mirai/mirai-api-http/issues/435 这个拒绝链接;若后台开着mcl再新命令行里使用python bot.py运行,就会得到这个404的错误

PS: 最近似乎启动mcl,自动更新了一些包=_=,更新了哪些没有记下来

PPS:解决方法,换Yiri.Mirai框架ᓚᘏᗢ

Moyulingjiu commented 3 years ago

而且同楼上的说法,我是关闭了console自动更新的,这次更新仍然更新了,更新之后就没办法启动了。同404

dwj1210 commented 3 years ago

我也是同样的问题。启动 mcl 后,运行 bot.py 就会 404 。实际访问 localhost:8080 也确实是访问不到。感觉 mcl 并没有监听这个端口。 这是 mcl 的部分输出日志:

2021-08-27 18:33:38 I/http adapter: >>> [http adapter] is listening at http://localhost:8080
2021-08-27 18:33:38 I/Mirai HTTP API: Http api server is running with verifyKey: INITKEYe4LKDpYB
2021-08-27 18:33:38 I/Mirai HTTP API: adaptors: [http]
2021-08-27 18:33:38 I/Mirai HTTP API: ********************************************************
2021-08-27 18:33:38 I/main: 2 plugin(s) enabled.
2021-08-27 18:33:38 I/main: mirai-console started successfully.