1. 报错详细

05-27 14:54:21 [ERROR] nonebot | QQ | Error while setup websocket to wss://api.sgroup.qq.com/websocket. Trying to reconnect...
Traceback (most recent call last):
File "/Users/xiayuan/Documents/Code/modernia-bot/bot.py", line 17, in <module>
nonebot.run()
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/nonebot/__init__.py", line 337, in run
get_driver().run(*args, **kwargs)
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/nonebot/drivers/fastapi.py", line 187, in run
uvicorn.run(
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/uvicorn/main.py", line 580, in run
server.run()
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/uvicorn/server.py", line 66, in run
return asyncio.run(self.serve(sockets=sockets))
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 194, in run
return runner.run(main)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
> File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/nonebot/adapters/qq/adapter.py", line 200, in _forward_ws
async with self.websocket(request) as ws:
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 214, in __aenter__
return await anext(self.gen)
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/nonebot/internal/adapter/adapter.py", line 99, in websocket
async with self.driver.websocket(setup) as ws:
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 214, in __aenter__
return await anext(self.gen)
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/nonebot/drivers/websockets.py", line 81, in websocket
async with connection as ws:
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/websockets/legacy/client.py", line 633, in __aenter__
return await self
File "/Users/xiayuan/Documents/Code/modernia-bot/.venv/lib/python3.13/site-packages/websockets/legacy/client.py", line 652, in __await_impl__
_transport, protocol = await self._create_connection()
File "uvloop/loop.pyx", line 2088, in create_connection
raise
File "uvloop/loop.pyx", line 2083, in uvloop.loop.Loop.create_connection
await ssl_waiter
File "uvloop/sslproto.pyx", line 517, in uvloop.loop.SSLProtocol._on_handshake_complete
raise handshake_exc
File "uvloop/sslproto.pyx", line 499, in uvloop.loop.SSLProtocol._do_handshake
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ssl.py", line 951, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1020)

问题分析(来自GPT):

这是一个典型的 SSL 证书验证失败 错误,原因是 NoneBot 的 QQ 适配器尝试连接 wss://api.sgroup.qq.com/websocket 时,发现返回的证书链中包含了自签名证书(self-signed certificate),而你的 Python 解释器出于安全考虑默认拒绝了它。

这通常在以下几种情况下出现:

系统或 Python 没有正确的 CA 根证书列表(在 macOS 上尤其常见)。

你本地或中间代理劫持了 SSL 流量并使用了自签名证书(比如公司内网、某些防火墙、某些 VPN)。

QQ 的服务器有问题,但可能性较小。

解决办法

使用 Python 安装证书工具(macOS 推荐)

你是在 macOS 下运行的 Python 3.13,可以尝试运行:

/Applications/Python\ 3.13/Install\ Certificates.command

这个命令会安装或修复 Python 使用的系统根证书,解决大部分 macOS 上的 CERTIFICATE_VERIFY_FAILED 问题。

其他关键词

nonebot2连接报错

QQ机器人websocket连接报错

【nonebot2】QQ适配器websocket连接报错的更多相关文章

  1. 解决oracle服务器重启之后连接报错的问题

    DB服务器重启之后再连接报错如下: 原因是重启之后listener.ora被还原成初始文件,sid被清空. 解决步骤: 1.查看监听服务和数据库服务: 由此找到listener.ora文件的路径:D: ...

  2. 监听报错 TNS-00525: Insufficient privilege for operation 11gR2 + 连接报错ORA-12537: TNS:connection closed

    1.TNS-00525: Insufficient privilege for operation Started with pid= Listening on: (DESCRIPTION=(ADDR ...

  3. Oracle SQL Developer连接报错(ORA-12505)

    Oracle SQL Developer连接报错(ORA-12505) 之前我的Oracle数据库出现问题,费大波周折终于弄好了,今天又创建了一个DBA管理员的连接方式出现问题,本人现在把解决方案分享 ...

  4. 启动tomcat直接报错:org.apache.tomcat.util.digester.Digester startElement

    今天很奇怪,自己手动搭建了一个ssm(spring+springmvc+mybatis)的项目,然后添加到tomcat下,启动直接报错: 2017-3-19 9:24:47 org.apache.to ...

  5. Jmeter录制脚本过程及Could not create script recorder报错、您的连接不是私密连接报错

    转载自    https://www.cnblogs.com/wwho/p/7173172.html Jmeter录制脚本过程及Could not create script recorder报错.您 ...

  6. Oracle 12c SQL Developer连接报错(ORA-12505)

    Oracle 12c SQL Developer连接报错(ORA-12505) 连接时报错码:Listener refused the connection with following error: ...

  7. 二、Jmeter录制脚本过程及Could not create script recorder报错、您的连接不是私密连接报错

    两个报错:Could not create script recorder报错和您的连接不是私密连接报错 1.录制过程 * 打开jmeter * 点击Templated,选择Recoding模版 * ...

  8. ssh连接报错Write failed: Broken pipe Resource temporarily unavailable

    问题描述 使用root连接服务器正常,切换普通用户连接报错 具体报错如下:Write failed: Broken pipe 或者:failed to execute /bin/bash: Resou ...

  9. Mysql远程连接报错:SQL Error (1130): Host '192.168.61.128' is not allowed to connect to this MySQL server

    Mysql远程连接报错:SQL Error (1130): Host '192.168.0.18' is not allowed to connect to this MySQL server     ...

  10. Python 字符串与数字拼接报错

    Python 不像 JS 或者 PHP 这种弱类型语言里在字符串连接时会自动转换类型,而是直接报错. 如: 上述是Python 字符串与数字拼接报错,解决办法是:使用bytes函数把int型转换为st ...

随机推荐

  1. 关于Primavera P6版本选择上的一些看法

    从开始接触P6到目前也有近6年的时间,从最开始用的V7 (除P6.2.1)到现在用的18.8.0 ,除去一些小版本,中间自己跨越了8个不同版本    7.0,  (2013)    8.2       ...

  2. BUUCTF---rot

    题目 破解下面的密文: 83 89 78 84 45 86 96 45 115 121 110 116 136 132 132 132 108 128 117 118 134 110 123 111 ...

  3. frxpngimage单元的编译错误:frxpngimage left side cannot be assigned to

    一个老项目中,使用软数字录入数据,编译时出现n个:frxpngimage left side cannot be assigned to 原因是使用了frxpngimage单元,在D11中编译出现若干 ...

  4. 一文彻底搞懂 MCP:AI 大模型的标准化工具箱

    MCP 最近在 AI 领域 引发了 广泛关注,特别是在 海外各大社区 中,大家热烈讨论,热度 相当高. 我打开了 Google Trends,这是一个专门用于查看全球热点趋势的网站. 输入关键词后,可 ...

  5. LinkedBlockingQueue的poll方法底层原理

    一.LinkedBlockingQueue的poll方法底层原理 LinkedBlockingQueue 的 poll 方法用于从队列头部移除并返回元素.如果队列为空,poll 方法会立即返回 nul ...

  6. 手把手带你从论文出发实战搭建分割FCN网络

    作者:SkyXZ CSDN:SkyXZ--CSDN博客 博客园:SkyXZ - 博客园 FCN论文地址:Fully Convolutional Networks for Semantic Segmen ...

  7. where 闭包查询

    $map1[] = ["like_article.user_id", 'not in', function ($query) use ($user_id) { $query-> ...

  8. 拆解 Cursor Pro 自动化工具,看看它是怎么实现的?

    深入解析Cursor Pro自动化工具的核心实现 ‍ 从源码角度剖析关键技术 完整解读:注册.认证.机器码重置的自动化方案 项目概述 大家好,我是松哥.这篇文章将为大家详细解析一个Cursor自动化管 ...

  9. 基于Java Swing开发好看的皮肤

    先介绍几款开源及商业的皮肤. Weblaf:非常赞的套件,界面现代.简约.依赖包较少. 有开源也有商业协议,个人最喜欢的皮肤.https://github.com/mgarin/weblaf PgsL ...

  10. Java开发手册——【强制】所有整型包装类对象之间值的比较,全部使用 equals 方法比较

    Java开发手册说明: 对于 Integer var = ? 在-128 至 127 之间的赋值,Integer 对象是在 IntegerCache.cache 产生,会复用已有对象,这个区间内的 I ...