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

docker-扫了二维码就报错,电脑网页版微信也一直登录不了. #1137

Open
2 tasks done
daidaixiaoge opened this issue May 23, 2023 · 4 comments
Open
2 tasks done
Labels
deployment question Question from deployment

Comments

@daidaixiaoge
Copy link

前置确认

  • 我确认我运行的是最新版本的代码,并且安装了所需的依赖,在FAQS中也未找到类似问题。

⚠️ 搜索issues中是否已存在类似问题

  • 我已经搜索过issues和disscussions,没有跟我遇到的问题相关的issue

操作系统类型?

Docker

运行的python版本是?

python 3.8

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

wx(个人微信, itchat)

复现步骤 🕹

No response

问题描述 😯

File "/root/server/temp/chatgpt-on-wechat-master/lib/itchat/components/login.py", line 177, in process_login_info
r = core.s.get(core.loginInfo['url'],
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='wx8.qq.com', port=443): Max retries exceeded with url: /cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=CDIsBht0ZusFk_fv9zHBv_4O@qrticket_0&uuid=QZCwLoyp0A==&lang=zh_CN&scan=1684805216 (Caused by SSLError(CertificateError("hostname 'wx8.qq.com' doesn't match either of 'wx.qq.com', '.web.wechat.com', '.web1.wechat.com', '.web2.wechat.com', '.wechat.com', '.weixin.qq.com', '.wx.qq.com', '.wx1.qq.com', '.wx2.qq.com', 'wechat.com', 'weixin.qq.com', 'wx1.qq.com', 'wx2.qq.com'")))

终端日志 📒

<此处粘贴终端日志>
@lanvent
Copy link
Collaborator

lanvent commented May 23, 2023

这个跟#1123 里的问题一样, 是wx自动分配的wx8.qq.com域名没有添加到证书里。
试试把以下代码加进app.py的import部分之后

import ssl
ssl.match_hostname = lambda cert, hostname: True

@lanvent lanvent added deployment question Question from deployment and removed status: needs check labels May 23, 2023
@iwill87
Copy link

iwill87 commented May 24, 2023

有一个临时解决办法(忽略证书检查、不安全):

  1. 在环境中找到 itchat 位置
pip show itchat-uos
  1. 进入Location:显示的路径, 修改当前路径下 ./itchat/core.py, 在 init 中找到
self.s = requests.Session()
  1. 在下方加入
self.s.verify = False

修改后会在 log 中出现很多警告,如需忽略在该文件中import requests下方加入:

from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

@xie-yao-oos
Copy link

非常感谢楼上,不过在您最后的两个排除警告的有点小小意见:

from requests.packages.urllib3.exceptions import InsecureRequestWarning

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

这段代码的作用是禁用Requests库中的InsecureRequestWarning警告,以避免在使用不安全的HTTPS请求时出现该警告。
优化建议:
可以使用以下代码替换上述代码,更简洁地实现同样的效果:

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

这段代码的作用和原代码相同,只是使用了urllib3库中的disable_warnings函数来禁用InsecureRequestWarning警告。由于urllib3库是Requests库的底层依赖库,因此可以直接使用该库来禁用警告,避免了引入额外的包。

@oasiszeng
Copy link

lambda

在app.py中插入代码块,报错问题仍存在

# encoding:utf-8

import os
import signal
import sys
# 
import ssl
ssl.match_hostname = lambda cert, hostname: True

from channel import channel_factory
from common.log import logger
from config import conf, load_config
from plugins import *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployment question Question from deployment
Projects
None yet
Development

No branches or pull requests

5 participants