作者归档:杨龙

微信H5支付无法唤起APP支付的问题

因为请求头部少了“Sec-Fetch-User: ?1”就不行了,可能和微信的安全机制有关

可以:

GET https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=xxx&package=xxx&redirect_url=xxx HTTP/1.1
Host: wx.tenpay.com
Connection: keep-alive
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?1
Upgrade-Insecure-Requests: 1
DNT: 1
User-Agent: Mozilla/5.0 (Linux; Android 10; MI 9 Transparent Edition) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.86 Mobile Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://m.xxx.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh-TW;q=0.9,zh;q=0.8,en-US;q=0.7,en;q=0.6

不行:

GET https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=xxx&package=xxx&redirect_url=xxx HTTP/1.1
Host: wx.tenpay.com
Connection: keep-alive
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?1
Upgrade-Insecure-Requests: 1
DNT: 1
User-Agent: Mozilla/5.0 (Linux; Android 10; MI 9 Transparent Edition) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.86 Mobile Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-Dest: document
Referer: http://m.xxx.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh-TW;q=0.9,zh;q=0.8,en-US;q=0.7,en;q=0.6

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

把server_names_hash_bucket_size改大点即可,可以改成64或128试下,放在http {}里

Syntax:server_names_hash_bucket_size size;
Default:server_names_hash_bucket_size 32|64|128;
Context:http

Sets the bucket size for the server names hash tables. The default value depends on the size of the processor’s cache line. The details of setting up hash tables are provided in a separate document.

Entity: line 39: parser error : Entity ‘nbsp’ not defined

在 XML 中,只有 5 个预定义的实体引用,$nbsp; 应该替换为空格~

$content = Entities::replaceAllEntities($content);

在 XML 中,有 5 个预定义的实体引用:

&lt;<小于
&gt;>大于
&amp;&和号
&apos;单引号
&quot;引号

注释:在 XML 中,只有字符 “<” 和 “&” 确实是非法的。大于号是合法的,但是用实体引用来代替它是一个好习惯。

innodb_large_prefix

查看表结构,发现token这个字段类型是varchar(4000),默认情况下innodb下创建的索引最大长度是767字节,大概原因我们就知道了,由于字段长度过长,导致创建索引的长度有限,这样实际索引的区分度就非常低了,每次查询都要扫描很多的行,加上这个查询是一个高频的查询,导致了系统运行缓慢。

问题解决
这个问题有几种解决方式:

第一种:
修改数据库参数innodb_large_prefix设置为on,这样可以将创建索引的长度扩大到3072,这样可以提高索引数据的区分度,每次查询时扫描的行数就会降低。当天晚上修改了此参数后,查看执行计划rows扫描的行数就降至到了95,并且第二天也无此SQL的慢查询,慢查询日志文件也从前一天的60个文件较少到了1个

第二种:
通过增加缓存的方式,将token放到缓存中,减少对数据库的访问次数

原文地址

https://mp.weixin.qq.com/s/AzErO4Ri7Z48OgfZxp3sSg