ehForwarderBot / efb-wechat-slave

A channel for EH Forwarder Bot.
GNU Affero General Public License v3.0
458 stars 62 forks source link

[BUG] 频繁被登出 #150

Open Gaojianli opened 8 months ago

Gaojianli commented 8 months ago

版本信息 Version Info

EH Forwarder Bot
Version: 2.1.1
Python version:
3.11.6 (main, Oct 13 2023, 15:52:55) [GCC 13.1.1 20230722]
Running on profile "default".

Master channel:
    Telegram Master (blueset.telegram) 2.3.1 # Default instance

Slave channel:
    WeChat Slave (blueset.wechat) 2.0.7 # Default instance

Middlewares:
    No middleware is enabled.

问题描述 Describe the bug

从今天(2024.2.6)下午开始,EFB频繁开始登出,日志中存在大量报错(见日志)

但是使用curl 请求日志中的URL并无任何问题,因此排除网络原因:

 # curl "https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck?r=1707211056730&skey=&sid=tP7ipEnKPuQMyVaf&uin=1415579330&deviceid=
e875955993501925&synckey=1_850644928%7C2_850646176%7C3_850646133%7C11_850646060%7C19_36191%7C23_1707210984%7C24_1707211055%7C25_850646
176%7C27_1530117%7C201_1707211055%7C206_103%7C1000_1707210509%7C1001_1707204662&_=1707210991286" -v
*   Trying 43.159.235.194:443...
* Connected to webpush.wx2.qq.com (43.159.235.194) port 443
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: C=CN; ST=Guangdong Province; L=Shenzhen; O=Shenzhen Tencent Computer Systems Company Limited; CN=wx.qq.com
*  start date: Jun 29 00:00:00 2023 GMT
*  expire date: Jun 28 23:59:59 2024 GMT
*  subjectAltName: host "webpush.wx2.qq.com" matched cert's "*.wx2.qq.com"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Secure Site CN CA G3
*  SSL certificate verify ok.
* using HTTP/1.x
> GET /cgi-bin/mmwebwx-bin/synccheck?r=1707211056730&skey=&sid=tP7ipEnKPuQMyVaf&uin=1415579330&deviceid=e875955993501925&synckey=1_850644928%7C2_850646176%7C3_850646133%7C11_850646060%7C19_36191%7C23_1707210984%7C24_1707211055%7C25_850646176%7C27_1530117%7C201_1707211055%7C206_103%7C1000_1707210509%7C1001_1707204662&_=1707210991286 HTTP/1.1
> Host: webpush.wx2.qq.com
> User-Agent: curl/8.4.0
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
< HTTP/1.1 200 OK
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< Content-Type: text/javascript
< Content-Length: 46
< 
* Connection #0 to host webpush.wx2.qq.com left intact
window.synccheck={retcode:"1102",selector:"0"}

重现步骤 To Reproduce

尝试登陆,正常工作数分钟,被登出

截图 Screenshots

image

Verbose 日志 Log

Verbose 日志 ``` During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 357, in sync_check r = self.s.get(url, params=params, headers=headers, timeout=config.TIMEOUT) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 602, in get return self.request("GET", url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/efb_wechat_slave/vendor/wxpy/utils/misc.py", line 350, in customized_request return requests.Session.request(session, method, url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 519, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='webpush.wx2.qq.com', port=443): Max retries exceeded with url: /cgi-bin/mmwebwx-bin/synccheck?r=1707211427761&skey=&sid=tP7ipEnKPuQMyVaf&uin=1415579330&deviceid=e884754366085969&synckey=1_850644928%7C2_850646233%7C3_850646133%7C11_850646060%7C19_36191%7C23_1707210984%7C24_1707211383%7C25_850646233%7C27_1530173%7C201_1707211383%7C206_103%7C1000_1707210509%7C1001_1707204662&_=1707210991362 (Caused by ProtocolError('Connection aborted.', BadStatusLine('HTTP/1.1 0 -\r\n'))) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 298, in maintain_loop i = sync_check(self) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 360, in sync_check if not isinstance(e.args[0].args[1], BadStatusLine): ~~~~~~~~~~~~~~^^^ IndexError: tuple index out of range ```

备注 Additional context

QieSen commented 7 months ago

SAME issue!!

一开始是很快被登出,目前已无法正常使用EWS登录。日志中提示: Exception: server refused, loading login status failed.

之前已稳定使用两年,并且网页版微信能够正常登录使用。

附组件版本信息:

您正在使用 EFB Telegram 主端 2.3.1,运行于默认配置档案与实例、EFB 版本 2.1.1。
已激活 1 个从端:
- 💬 WeChat Slave (blueset.wechat, 2.0.7)

已启用 2 个中间件:
- Patch Middleware (patch.PatchMiddleware, 2.0.23)
- Notice Middleware (notice.NoticeMiddleware, 0.0.6)

具体日志(已脱敏): https://gist.github.com/QieSen/8dec631664555a9e4019f81662eb57b2

Gaojianli commented 7 months ago

SAME issue!!

一开始是很快被登出,目前已无法正常使用EWS登录。日志中提示: Exception: server refused, loading login status failed.

之前已稳定使用两年,并且网页版微信能够正常登录使用。

附组件版本信息:

您正在使用 EFB Telegram 主端 2.3.1,运行于默认配置档案与实例、EFB 版本 2.1.1。
已激活 1 个从端:
- 💬 WeChat Slave (blueset.wechat, 2.0.7)

已启用 2 个中间件:
- Patch Middleware (patch.PatchMiddleware, 2.0.23)
- Notice Middleware (notice.NoticeMiddleware, 0.0.6)

具体日志(已脱敏): https://gist.github.com/QieSen/8dec631664555a9e4019f81662eb57b2

我暂时解决了,方法是修改 efb_wechat_slave/vendor/itchat/components/login.py:360e.args[0].args[1]修改为e.args[0].reason.args[1]

churchilldu commented 7 months ago

我暂时解决了,方法是修改 efb_wechat_slave/vendor/itchat/components/login.py:360e.args[0].args[1]修改为e.args[0].reason.args[1]

works perfectly! lifesaver man

kettly1260 commented 7 months ago

2024-03-04 00:32:56,123 [ERROR]: telegram.ext.updater (updater._network_loop_retry; updater.py:664) Error while getting Updates: urllib3 HTTPError SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: aaaaaaaaaaaaaaaaa (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x7ff820ff56a0>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')) 2024-03-04 00:32:56,173 [ERROR]: efb_telegram_master (init.error; init.py:496) Poor internet connection detected. Number of network error occurred since last startup: 2 urllib3 HTTPError SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /aaaaaaaaaaaaaaaaaaa (Caused by ConnectTimeoutError(<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x7ff820ff56a0>, 'Connection to api.telegram.org timed out. (connect timeout=5.0)')) Update: None Exception in thread EWS reauth thread: Traceback (most recent call last): File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner self.run() File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/threading.py", line 917, in run self._target(*self._args, **self._kwargs) File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/init.py", line 672, in authenticate self.bot: wxpy.Bot = wxpy.Bot(cache_path=str(efb_utils.get_data_path(self.channel_id) / "wxpy.pkl"), File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/vendor/wxpy/api/bot.py", line 85, in init self.core.auto_login( File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/vendor/itchat/components/register.py", line 32, in auto_login self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback, File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 58, in login status = self.check_login() File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 171, in check_login if process_login_info(self, r.text): File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/site-packages/efb_wechat_slave/vendor/itchat/components/login.py", line 211, in process_login_info for node in xml.dom.minidom.parseString(r.text).documentElement.childNodes: File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/xml/dom/minidom.py", line 1998, in parseString return expatbuilder.parseString(string) File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/xml/dom/expatbuilder.py", line 925, in parseString return builder.parseString(string) File "/home/ubuntu/anaconda3/envs/efb3.9/lib/python3.9/xml/dom/expatbuilder.py", line 223, in parseString parser.Parse(string, True) xml.parsers.expat.ExpatError: mismatched tag: line 64, column 4

用过以上方法,还是频繁登出