Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Nonebot2通过正向Websocket连接go-cqhttp报错400 #560

Closed
Kaleidoscope39 opened this issue Oct 11, 2021 · 5 comments · Fixed by #561
Closed

Bug: Nonebot2通过正向Websocket连接go-cqhttp报错400 #560

Kaleidoscope39 opened this issue Oct 11, 2021 · 5 comments · Fixed by #561
Labels
bug Something isn't working

Comments

@Kaleidoscope39
Copy link

Kaleidoscope39 commented Oct 11, 2021

描述问题:

在目前最新的Nonebot2的release中使用websocket与go-cqhttp进行连接会报错400。
这个问题仅出现在了Linux端上,在Win环境下并不会出现400错误(无论是go-cqhttp运行在linux还是win下)。
此问题已经在私下测试完成复现了很多次。

如何复现?

前提条件:

  • go-cqhttp已完成配置,连接协议为ws,host为127.0.0.1,port为6700,不启用access_token
  • 已完成安装nb-cli并安装nonebot-adapter-cqhttp且创建了一个新的机器人,使用cqhttp(Nonebot2)、.env.dev已添加配置 CQHTTP_WS_URLS={"2461591632": "ws://127.0.0.1:6700/"}
  1. 先行启动go-cqhttp服务
  2. 然后启动nonebot2机器人

期望的结果
go-cqhttp并没有任何报错,所以不贴东西了。

Nonebot2端报错:

10-11 11:49:35 [ERROR] nonebot | Error while connecting to ws://127.0.0.1:6700/. Try to reconnect...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/usr/lib/python3.9/multiprocessing/spawn.py", line 129, in _main
    return self._bootstrap(parent_sentinel)
  File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/ls420/.local/lib/python3.9/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
    target(sockets=sockets)
  File "/home/ls420/.local/lib/python3.9/site-packages/uvicorn/server.py", line 68, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
> File "/usr/local/lib/python3.9/dist-packages/nonebot/drivers/fastapi.py", line 489, in _ws_loop
    async with connection as ws:
  File "/home/ls420/.local/lib/python3.9/site-packages/websockets/legacy/client.py", line 604, in __aenter__
    return await self
  File "/home/ls420/.local/lib/python3.9/site-packages/websockets/legacy/client.py", line 629, in __await_impl__
    await protocol.handshake(
  File "/home/ls420/.local/lib/python3.9/site-packages/websockets/legacy/client.py", line 388, in handshake
    raise InvalidStatusCode(status_code)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 400

环境信息:

  • OS: [Ubuntu20.04-LTS_arm64/amd64]
  • Python Version: [3.9.5]
  • Nonebot Version: [2.0.0a16]

协议端信息:

  • 协议端: [go-cqhttp]
  • 协议端版本: [v1.0.0-beta7-fix2]

截图或日志

@Kaleidoscope39 Kaleidoscope39 added the bug Something isn't working label Oct 11, 2021
@yanyongyu
Copy link
Member

CQHTTP_WS_URLS={"QQ": "ws://127.0.0.1:6700/"}

请正确填写你的QQ号

@Kaleidoscope39
Copy link
Author

CQHTTP_WS_URLS={"QQ": "ws://127.0.0.1:6700/"}

请正确填写你的QQ号

Done

@yanyongyu
Copy link
Member

依然报错?

@Kaleidoscope39
Copy link
Author

依然报错?

这个错误本身与这个无关的,只是我懒没写上QQ号😶

@yanyongyu
Copy link
Member

yanyongyu commented Oct 11, 2021

fixed in dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants