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

mac、node18以上版本不兼容,代理出现状态码502 #1013

Closed
Hokori23 opened this issue Nov 23, 2023 · 15 comments
Closed

mac、node18以上版本不兼容,代理出现状态码502 #1013

Hokori23 opened this issue Nov 23, 2023 · 15 comments

Comments

@Hokori23
Copy link

Hokori23 commented Nov 23, 2023

芯片:Apple M2 Pro
OS版本:macOS Ventura13.5.2
whistle:版本2.9.59
node版本:18.18.2、20.10.0


node版本降到16.20.2则代理成功

@avwo
Copy link
Owner

avwo commented Nov 23, 2023

导出抓包看下

@jing2si
Copy link

jing2si commented Dec 1, 2023

From: whistle@2.9.59
Node: v18.18.0
Host: MacBook.local
Date: 12/1/2023, 3:57:18 PM
TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at Url.parse (node:url:442:17)
    at urlParse (node:url:167:13)
    at module.exports [as parseUrl] (/Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/util/parse-url.js:9:12)
    at /Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/inspectors/rules.js:41:26
    at /Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/plugins/index.js:1322:5
    at getRulesMgr (/Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/plugins/index.js:1314:12)
    at pluginMgr.getRules (/Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/plugins/index.js:1464:3)
    at /Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/inspectors/rules.js:33:15
    at /Users/xxx/.nvm/versions/node/v18.18.0/lib/node_modules/whistle/lib/rules/index.js:493:5

我遇到类似502的问题,上面👆是错误的 response,我的 node 版本是 18.18.0,我降级到 14.17.0 也是正常的。
我是使用 Mock 数据才会出现这样的问题

Rules

xxx.com file://{products.json}

Values

products.json

502报错数据

[
  {
    "test": "#"
  }
]

200正常数据

[
  {
    "test": ""
  }
]
{
  "test": "#"
}

看情况和 # 号有关系

@avwo
Copy link
Owner

avwo commented Dec 1, 2023

Node 底层实现改了,下个版本修复

@avwo
Copy link
Owner

avwo commented Dec 7, 2023

重新安装最新版本试试

@avwo avwo closed this as completed Dec 7, 2023
@jayjliang
Copy link

升级到2.9.62还是不行,nodejs版本:18.19.0

@avwo
Copy link
Owner

avwo commented Jan 10, 2024

看下 Online 允许的是不是最新版本,把抓包导出我看下

@jayjliang
Copy link

看下 Online 允许的是不是最新版本,把抓包导出我看下

[
{
"useH2": false,
"startTime": 1704860097813,
"id": "1704860097811-020",
"url": "xxx",
"req": {
"method": "GET",
"httpVersion": "1.1",
"ip": "127.0.0.1",
"port": "58908",
"rawHeaderNames": {
"connection": "Connection",
"proxy-authorization": "Proxy-Authorization"
},
"headers": {
"host": "localhost:9001",
"sec-ch-ua": ""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": ""macOS"",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 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.7",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "iframe",
"referer": "xxxx",
"accept-encoding": "gzip",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"cookie": "xxx",
"connection": "close"
},
"size": 0,
"body": false,
"rawHeaders": {
"host": "localhost:9001",
"sec-ch-ua": ""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": ""macOS"",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 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.7",
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "iframe",
"referer": "xxx",
"accept-encoding": "gzip",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"cookie": "xxx",
"Connection": "close"
}
},
"res": {
"ip": "::1",
"port": "9001",
"rawHeaderNames": {},
"statusCode": 502,
"headers": {
"content-type": "text/html; charset=utf8",
"x-server": "whistle"
},
"size": 286,
"body": "",
"base64": "PHByZT4KRnJvbTogd2hpc3RsZUAyLjkuNjINCk5vZGU6IHYxOC4xOS4wDQpIb3N0OiBCLTBHR0o3VExXLTAxNDQubG9jYWwNCkRhdGU6IDIwMjQvMS8xMCAxMjoxNDo1Nw0KRXJyb3I6IGNvbm5lY3QgRUNPTk5SRUZVU0VEIDo6MTo5MDAxCiAgICBhdCBUQ1BDb25uZWN0V3JhcC5hZnRlckNvbm5lY3QgW2FzIG9uY29tcGxldGVdIChub2RlOm5ldDoxNTU1OjE2KQoKCjxhIGhyZWY9ImphdmFzY3JpcHQ6OyIgb25jbGljaz0ibG9jYXRpb24ucmVsb2FkKCkiPlJlbG9hZCB0aGlzIHBhZ2U8L2E+CjwvcHJlPg==",
"rawHeaders": {
"content-type": "text/html; charset=utf8",
"x-server": "whistle"
}
},
"rules": {
"rule": {
"url": "xxx",
"files": null,
"not": false,
"name": "rule",
"root": null,
"isRegExp": true,
"protocol": null,
"pattern": {},
"matcher": "xxx",
"raw": "xxxx",
"isDomain": false,
"rawPattern": "xxx",
"lineProps": {},
"isTpl": false
}
},
"rulesHeaders": {},
"version": "2.9.62",
"nodeVersion": "18.19.0",
"dnsTime": 1704860097813,
"realUrl": "xxx",
"httpsTime": 1704860097823,
"useHttp": true,
"requestTime": 1704860097825,
"responseTime": 1704860097826,
"endTime": 1704860097827,
"method": "GET",
"hostIp": "::1",
"clientIp": "127.0.0.1",
"date": "2024/1/10 12:14:57.813",
"clientPort": "58908",
"serverPort": "9001",
"contentEncoding": "",
"body": "0 + 286",
"result": 502,
"type": "text/html",
"time": "14ms",
"download": "1ms",
"response": "1ms",
"request": "12ms",
"dns": "0ms",
"protocol": "HTTPS > HTTP",
"hostname": "xxxx",
"path": "xxx",
"order": 2,
"hide": false,
"lost": true,
"selected": true,
"active": true
}
]

@avwo
Copy link
Owner

avwo commented Jan 10, 2024

没匹配到规则,自己先看下

image

@jayjliang
Copy link

没匹配到规则,自己先看下

image

这个代理抓包删除了部分内容,因为里面的规则涉及隐私,我重新配了一份不涉及隐私的
目前看起来就是因为protocol有个https->http,而本地服务是不支持http的,只支持https

[
{
"useH2": false,
"startTime": 1704874264787,
"id": "1704874264786-182",
"url": "https://www.test.com/index.html",
"req": {
"method": "GET",
"httpVersion": "1.1",
"ip": "127.0.0.1",
"port": "64523",
"rawHeaderNames": {
"connection": "Connection",
"proxy-authorization": "Proxy-Authorization"
},
"headers": {
"host": "localhost:9001",
"pragma": "no-cache",
"cache-control": "no-cache",
"sec-ch-ua": ""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": ""macOS"",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 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.7",
"sec-fetch-site": "none",
"sec-fetch-mode": "navigate",
"sec-fetch-user": "?1",
"sec-fetch-dest": "document",
"accept-encoding": "gzip",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"connection": "close"
},
"size": 0,
"body": false,
"rawHeaders": {
"host": "localhost:9001",
"pragma": "no-cache",
"cache-control": "no-cache",
"sec-ch-ua": ""Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": ""macOS"",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 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.7",
"sec-fetch-site": "none",
"sec-fetch-mode": "navigate",
"sec-fetch-user": "?1",
"sec-fetch-dest": "document",
"accept-encoding": "gzip",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"Connection": "close"
}
},
"res": {
"ip": "::1",
"port": "9001",
"rawHeaderNames": {},
"statusCode": 502,
"headers": {
"content-type": "text/html; charset=utf8",
"x-server": "whistle"
},
"size": 286,
"body": "",
"base64": "PHByZT4KRnJvbTogd2hpc3RsZUAyLjkuNjINCk5vZGU6IHYxOC4xOS4wDQpIb3N0OiBCLTBHR0o3VExXLTAxNDQubG9jYWwNCkRhdGU6IDIwMjQvMS8xMCAxNjoxMTowNA0KRXJyb3I6IGNvbm5lY3QgRUNPTk5SRUZVU0VEIDo6MTo5MDAxCiAgICBhdCBUQ1BDb25uZWN0V3JhcC5hZnRlckNvbm5lY3QgW2FzIG9uY29tcGxldGVdIChub2RlOm5ldDoxNTU1OjE2KQoKCjxhIGhyZWY9ImphdmFzY3JpcHQ6OyIgb25jbGljaz0ibG9jYXRpb24ucmVsb2FkKCkiPlJlbG9hZCB0aGlzIHBhZ2U8L2E+CjwvcHJlPg==",
"rawHeaders": {
"content-type": "text/html; charset=utf8",
"x-server": "whistle"
}
},
"rules": {
"rule": {
"files": null,
"url": "https://localhost:9001/static-flex-table-app/index.html",
"not": false,
"name": "rule",
"root": null,
"isRegExp": false,
"protocol": null,
"pattern": "www.test.com/index.html",
"matcher": "https://localhost:9001/static-flex-table-app/index.html",
"raw": "www.test.com/index.html https://localhost:9001/static-flex-table-app/index.html",
"isDomain": false,
"rawPattern": "www.test.com/index.html",
"lineProps": {},
"isTpl": false
}
},
"rulesHeaders": {},
"version": "2.9.62",
"nodeVersion": "18.19.0",
"dnsTime": 1704874264787,
"realUrl": "https://localhost:9001/static-flex-table-app/index.html",
"httpsTime": 1704874264801,
"useHttp": true,
"requestTime": 1704874264803,
"responseTime": 1704874264805,
"endTime": 1704874264807,
"method": "GET",
"hostIp": "::1",
"clientIp": "127.0.0.1",
"date": "2024/1/10 16:11:04.787",
"clientPort": "64523",
"serverPort": "9001",
"contentEncoding": "",
"body": "0 + 286",
"result": 502,
"type": "text/html",
"time": "20ms",
"download": "2ms",
"response": "2ms",
"request": "16ms",
"dns": "0ms",
"protocol": "HTTPS > HTTP",
"hostname": "www.test.com",
"path": "/index.html",
"order": 1,
"hide": false,
"lost": true,
"selected": true,
"active": true
}
]

@avwo
Copy link
Owner

avwo commented Jan 10, 2024

本地服务没起来

@jayjliang
Copy link

本地服务没起来

本地服务非常确认已经起来了哈,但是本地服务只支持https,直接通过https://localhost:9001/static-flex-table-app/index.html访问是可以的
image

目前看起来像是因为protocol有个https->http,而本地服务是不支持http的,只支持https

@avwo
Copy link
Owner

avwo commented Jan 10, 2024

localhost 改成 127.0.0.1 试试

@jayjliang
Copy link

localhost 改成 127.0.0.1 试试

可以了~请问这个是什么原因啊

@avwo
Copy link
Owner

avwo commented Jan 10, 2024

localhost 指向的是 ::1,你们服务没有监听这个网卡的端口

@jayjliang
Copy link

localhost 指向的是 ::1,你们服务没有监听这个网卡的端口

node 16.2是可以的,单纯把node切换到16.2就好了

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

No branches or pull requests

4 participants