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

v5.0.1版本点击"百度账号设置"加载时间很长甚至504 #261

Open
2 tasks done
zhufeng opened this issue Apr 18, 2024 · 10 comments
Open
2 tasks done

v5.0.1版本点击"百度账号设置"加载时间很长甚至504 #261

zhufeng opened this issue Apr 18, 2024 · 10 comments
Labels

Comments

@zhufeng
Copy link

zhufeng commented Apr 18, 2024

  • 我已升级贴吧云签到到最新版本,并且运行了升级脚本
  • 我已搜索过 Issue 区,没有找到相关问题

问题描述

v5.0.1版本点击"百度账号设置"加载时间很长甚至直接504。

复现步骤

点击"百度账号设置"。

环境

  • 云签到版本:v5.0.1
  • 服务器系统和版本:debian 12 最新补丁
  • 云签到是否在 Docker 中运行:否
    PHP 版本:8.2.18 非线程安全
    MySQL 版本:10.11.6-MariaDB-0+deb12u1
    服务器软件:nginx/1.22.1
    服务器系统:Linux ovm1 6.1.0-20-amd64 # 1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86_64

备注

查看php-fpm的日志无异常,但nginx日志有504的报错。

2024/04/18 17:57:18 [error] 454#454: *105 upstream timed out (110: Connection timed out) while reading response header from upstream, client: [IP], server: xxx.com, request: "GET /tieba/index.php?mod=baiduid HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx.com"

@n0099
Copy link
Collaborator

n0099 commented Apr 18, 2024

@zhufeng
Copy link
Author

zhufeng commented Apr 19, 2024

https://github.com/MoeNetwork/Tieba-Cloud-Sign/blob/09ca411da65a97808898e639466f85808c491153/templates/baiduid.php 看起来没有对外wcurl 是不是mysql慢查询?

这个要如何排查呢,账号里面在只添加了一个百度账号的情况下,也会出现加载慢的问题。
甚至刚初始化环境,还没添加账号的情况下,也会出现这个问题。

但是奇怪的是,除了这个账号设置页面,其它页面的加载速度都正常。

@n0099
Copy link
Collaborator

n0099 commented Apr 19, 2024

在该文件里到处乱插

echo date(DATE_ATOM) . PHP_EOL;

然后

curl -v 您的tc/index.php?mod=baiduid

看卡哪行了

@BANKA2017
Copy link
Collaborator

BANKA2017 commented Apr 19, 2024

<form method="post" id="addbdid_form" onsubmit="return false;">
<?php $login_info = misc::get_login_qrcode(); ?>
<img src="//<?=$login_info["imgurl"] ?>" alt="qrcode" class="thumbnail center-block">
<div id="addbdid_ver" style="display: none">
<input type="hidden" id="sign" value="<?=$login_info["sign"] ?>">
</div>
<a href="https://wappass.baidu.com/wp/?qrlogin=&sign=<?=$login_info["sign"] ?>" class="btn btn-default btn-block" target="_blank">网页授权</a>
<input type="submit" id="addbdid_submit" class="btn btn-primary btn-block" value="点击绑定">
</form>

这页有个拉取登录二维码信息的对外请求,注释掉或者删掉试试,如果仍不行就不清楚了

@n0099
Copy link
Collaborator

n0099 commented Apr 19, 2024

/**
* 获得二维码及sign
*/
public static function get_login_qrcode()
{
$resp = ["sign" => null, "imgurl" => null];
$get_qrcode = json_decode((new wcurl("https://passport.baidu.com/v2/api/getqrcode?lp=pc"))->get(), true);
if (isset($get_qrcode["imgurl"]) && isset($get_qrcode["sign"])) {
$resp = ["sign" => $get_qrcode["sign"], "imgurl" => $get_qrcode["imgurl"]];
}
return $resp;

@zhufeng
Copy link
Author

zhufeng commented Apr 19, 2024

<form method="post" id="addbdid_form" onsubmit="return false;">
<?php $login_info = misc::get_login_qrcode(); ?>
<img src="//<?=$login_info["imgurl"] ?>" alt="qrcode" class="thumbnail center-block">
<div id="addbdid_ver" style="display: none">
<input type="hidden" id="sign" value="<?=$login_info["sign"] ?>">
</div>
<a href="https://wappass.baidu.com/wp/?qrlogin=&sign=<?=$login_info["sign"] ?>" class="btn btn-default btn-block" target="_blank">网页授权</a>
<input type="submit" id="addbdid_submit" class="btn btn-primary btn-block" value="点击绑定">
</form>

这页有个拉取登录二维码信息的对外请求,注释掉或者删掉试试,如果仍不行就不清楚了

感谢,确实是这个问题。

把 get_login_qrcode()的所在这个140行注释掉,就正常了。
<?php $login_info = misc::get_login_qrcode(); ?>

@zhufeng
Copy link
Author

zhufeng commented Apr 19, 2024

/**
* 获得二维码及sign
*/
public static function get_login_qrcode()
{
$resp = ["sign" => null, "imgurl" => null];
$get_qrcode = json_decode((new wcurl("https://passport.baidu.com/v2/api/getqrcode?lp=pc"))->get(), true);
if (isset($get_qrcode["imgurl"]) && isset($get_qrcode["sign"])) {
$resp = ["sign" => $get_qrcode["sign"], "imgurl" => $get_qrcode["imgurl"]];
}
return $resp;

可能是ipv6的问题。

[root@ ~]# curl -v https://passport.baidu.com/v2/api/getqrcode?lp=pc
*   Trying [2409:8c00:6c21:109a:0:ff:b023:56f]:443...
* Connected to passport.baidu.com (2409:8c00:6c21:109a:0:ff:b023:56f) port 443 (#0)
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* Recv failure: Connection reset by peer
* OpenSSL SSL_connect: Connection reset by peer in connection to passport.baidu.com:443
* Closing connection 0
curl: (35) Recv failure: Connection reset by peer
[root@ovm1 ~]# curl -4 -v https://passport.baidu.com/v2/api/getqrcode?lp=pc
*   Trying 103.235.46.9:443...
* Connected to passport.baidu.com (103.235.46.9) port 443 (#0)
* ALPN: 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.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server accepted http/1.1
* Server certificate:
*  subject: C=CN; ST=beijing; L=beijing; O=Beijing Baidu Netcom Science Technology Co., Ltd; CN=baidu.com
*  start date: Jul  6 01:51:06 2023 GMT
*  expire date: Aug  6 01:51:05 2024 GMT
*  subjectAltName: host "passport.baidu.com" matched cert's "*.baidu.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign RSA OV SSL CA 2018
*  SSL certificate verify ok.
* using HTTP/1.1
> GET /v2/api/getqrcode?lp=pc HTTP/1.1
> Host: passport.baidu.com
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Access-Control-Expose-Headers: Trace-ID
< Connection: keep-alive
< Content-Length: 306
< Content-Type: application/json; charset=utf-8
< Date: Fri, 19 Apr 2024 02:13:23 GMT
< P3p: CP=" OTI DSP COR IVA OUR IND COM "
< Referrer-Policy: no-referrer-when-downgrade, strict-origin-when-cross-origin
< Server: BWS
< Set-Cookie: BAIDUID=*********
< Strict-Transport-Security: max-age=31536000
< Trace-Id:
< Tracecode: 34000073402849812490041910
<
* Connection #0 to host passport.baidu.com left intact
{"imgurl":"******"}

是否可以将wcurl()强制指定只解析v4地址,应该就能解决这个问题。

$get_qrcode = json_decode((new wcurl("https://passport.baidu.com/v2/api/getqrcode?lp=pc"))->get(), true);

@n0099
Copy link
Collaborator

n0099 commented Apr 19, 2024

https://stackoverflow.com/questions/25645634/force-ipv4-in-curl-in-php-application

-         $get_qrcode = json_decode((new wcurl("https://passport.baidu.com/v2/api/getqrcode?lp=pc"))->get(), true); 
+         $get_qrcode = json_decode((new wcurl("https://passport.baidu.com/v2/api/getqrcode?lp=pc"))->set(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4)->get(), true);

@ChloeKurumi
Copy link

请问怎么看自己装的什么版本?怎么升级?我用的是docer compose,但是装上后显示的4.95什么情况?

@n0099
Copy link
Collaborator

n0099 commented Jul 20, 2024

请问怎么看自己装的什么版本?

define('SYSTEM_VER', '5.01');

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

No branches or pull requests

4 participants