reqable / reqable-app

Reqable issue track repo
https://reqable.com
2.52k stars 85 forks source link

[bug] Mac 在开启代理一段时间之后端口无法使用,需要重启 Reqable #708

Open zsh2517 opened 2 weeks ago

zsh2517 commented 2 weeks ago

问题描述

按照时间顺序

Mac 打开 Reqable,启动。之后手机使用 Reqable Android 或者系统设置,配置代理连接。

正常抓包和使用一段时间后,发现正在测试的页面无法访问。

复现方式

没有明确的复现方式,无法简化到经过某些简单的操作后一定可以复现。

不过实际使用时,基本上每次打开并使用手机链接(主要是靠网络配置中设置代理,或者使用 Android APP)并且使用一段时间之后都能复现。

Q: 纯电脑使用测试过了吗? 没有。因为实际使用以电脑查看手机抓包为主,作为 Charles 的替代。没有电脑对电脑抓包的需求。 另外,未测试 windows/Linux。不确定是否可以复现

Q: 为什么要在手机的系统设置中配代理而非 App? mac 上在 /etc/hosts 配置了 127.0.0.1 example.com 后,在 Android 使用应用建立连接(好像是 VPN 模式)的情况下,无法通过 example.com:8080 访问到 127.0.0.1:8080,但是使用系统设置配置的代理可以。这一点后面我在其他环境验证后重新提一个 issue。这里暂不讨论

设备信息

提供代理的机器

被抓包的机器

可能相似的问题

277

404

其他说明

关于日志

因为是在公司环境使用的,因此不太方便公开日志。

我进行了一次完整的复现,下面是问题发生后的日志片段(应该有 curl -x 和 nping --tcp 的测试,但是分不出来哪个是哪个了)

https://pastebin.com/wkiiF6Nk

如果需要完整日志,希望作者能留一个邮箱或者其他方式,我单独发送

其他测试

设备自己的 IP 是 172.26.28.94,Reqable 监听的端口是 9002

nping / tcp ping

⋊> ~ sudo nping --tcp -p 9002 172.26.28.94 -v4

Starting Nping 0.7.95 ( https://nmap.org/nping ) at 2024-06-06 21:40 CST
SENT (0.0041s) TCP [172.26.28.94:49537 > 172.26.28.94:9002 S seq=3256946714 ack=0 off=5 res=0 win=1480 csum=0x6242 urp=0] IP [ver=4 ihl=5 tos=0x00 iplen=40 id=36 foff=0 ttl=64 proto=6 csum=0xe9bb]
0000   45 00 00 28 00 24 00 00  40 06 e9 bb ac 1a 1c 5e  E..(.$..@......^
0010   ac 1a 1c 5e c1 81 23 2a  c2 21 10 1a 00 00 00 00  ...^..#*.!......
0020   50 02 05 c8 62 42 00 00                           P...bB..
SENT (1.0042s) TCP [172.26.28.94:49537 > 172.26.28.94:9002 S seq=3256946714 ack=0 off=5 res=0 win=1480 csum=0x6242 urp=0] IP [ver=4 ihl=5 tos=0x00 iplen=40 id=36 foff=0 ttl=64 proto=6 csum=0xe9bb]
0000   45 00 00 28 00 24 00 00  40 06 e9 bb ac 1a 1c 5e  E..(.$..@......^
0010   ac 1a 1c 5e c1 81 23 2a  c2 21 10 1a 00 00 00 00  ...^..#*.!......
0020   50 02 05 c8 62 42 00 00                           P...bB..
SENT (2.0054s) TCP [172.26.28.94:49537 > 172.26.28.94:9002 S seq=3256946714 ack=0 off=5 res=0 win=1480 csum=0x6242 urp=0] IP [ver=4 ihl=5 tos=0x00 iplen=40 id=36 foff=0 ttl=64 proto=6 csum=0xe9bb]
0000   45 00 00 28 00 24 00 00  40 06 e9 bb ac 1a 1c 5e  E..(.$..@......^
0010   ac 1a 1c 5e c1 81 23 2a  c2 21 10 1a 00 00 00 00  ...^..#*.!......
0020   50 02 05 c8 62 42 00 00                           P...bB..
SENT (3.0066s) TCP [172.26.28.94:49537 > 172.26.28.94:9002 S seq=3256946714 ack=0 off=5 res=0 win=1480 csum=0x6242 urp=0] IP [ver=4 ihl=5 tos=0x00 iplen=40 id=36 foff=0 ttl=64 proto=6 csum=0xe9bb]
0000   45 00 00 28 00 24 00 00  40 06 e9 bb ac 1a 1c 5e  E..(.$..@......^
0010   ac 1a 1c 5e c1 81 23 2a  c2 21 10 1a 00 00 00 00  ...^..#*.!......
0020   50 02 05 c8 62 42 00 00                           P...bB..
SENT (4.0068s) TCP [172.26.28.94:49537 > 172.26.28.94:9002 S seq=3256946714 ack=0 off=5 res=0 win=1480 csum=0x6242 urp=0] IP [ver=4 ihl=5 tos=0x00 iplen=40 id=36 foff=0 ttl=64 proto=6 csum=0xe9bb]
0000   45 00 00 28 00 24 00 00  40 06 e9 bb ac 1a 1c 5e  E..(.$..@......^
0010   ac 1a 1c 5e c1 81 23 2a  c2 21 10 1a 00 00 00 00  ...^..#*.!......
0020   50 02 05 c8 62 42 00 00                           P...bB..

Max rtt: N/A | Min rtt: N/A | Avg rtt: N/A
Raw packets sent: 5 (200B) | Rcvd: 0 (0B) | Lost: 5 (100.00%)
Tx time: 4.00399s | Tx bytes/s: 49.95 | Tx pkts/s: 1.25
Rx time: 5.00506s | Rx bytes/s: 0.00 | Rx pkts/s: 0.00
Nping done: 1 IP address pinged in 5.01 seconds

curl with proxy

⋊> ~ curl -x localhost:9002 baidu.com -v
* Host localhost:9002 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:9002...
* connect to ::1 port 9002 from ::1 port 60036 failed: Connection refused
*   Trying 127.0.0.1:9002...
* connect to 127.0.0.1 port 9002 from 127.0.0.1 port 60037 failed: Operation timed out
* Failed to connect to localhost port 9002 after 25911 ms: Couldn't connect to server
* Closing connection
curl: (28) Failed to connect to localhost port 9002 after 25911 ms: Couldn't connect to server

lsof -i:port

⋊> ~ sudo lsof -i:9002
COMMAND     PID          USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Reqable   23521 USERNAME   35u  IPv4 0x3aef840ea923f0e0      0t0  TCP *:dynamid (LISTEN)
Reqable   23521 USERNAME   45u  IPv4 0xd1e930c4df35c43a      0t0  TCP 172.26.28.94:dynamid->172.26.6.45:41626 (ESTABLISHED)
Reqable   23521 USERNAME  130u  IPv4 0x7665fc99114c6815      0t0  TCP localhost:dynamid->localhost:53637 (ESTABLISHED)
Reqable   23521 USERNAME  184u  IPv4 0x1345d1ac37d5e1f1      0t0  TCP localhost:dynamid->localhost:55832 (CLOSED)
Reqable   23521 USERNAME  247u  IPv4 0xe8ebc08587804d92      0t0  TCP 172.26.28.94:dynamid->172.24.2.194:50323 (ESTABLISHED)
Google    86893 USERNAME   46u  IPv4 0xa51b031ae2695ec2      0t0  TCP localhost:53637->localhost:dynamid (ESTABLISHED)

lsof -i -a -p 23521

⋊> ~ sudo lsof -i -a -p 23521
COMMAND   PID          USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Reqable 23521 USERNAME   20u  IPv4 0xb49eabbde4be6df0      0t0  TCP *:12312 (LISTEN)
Reqable 23521 USERNAME   35u  IPv4 0x3aef840ea923f0e0      0t0  TCP *:dynamid (LISTEN)
Reqable 23521 USERNAME   41u  IPv4 0xf52b88b2d107666a      0t0  TCP *:12412 (LISTEN)
Reqable 23521 USERNAME   45u  IPv4 0xd1e930c4df35c43a      0t0  TCP 172.26.28.94:dynamid->172.26.6.45:41626 (ESTABLISHED)
Reqable 23521 USERNAME   46u  IPv4 0xe81c1cbe5cf5988d      0t0  TCP localhost:51414->localhost:12312 (ESTABLISHED)
Reqable 23521 USERNAME   49u  IPv4 0x61e43a40f60c5051      0t0  TCP localhost:12312->localhost:51414 (ESTABLISHED)
Reqable 23521 USERNAME  130u  IPv4 0x7665fc99114c6815      0t0  TCP localhost:dynamid->localhost:53637 (ESTABLISHED)
Reqable 23521 USERNAME  131u  IPv4 0xa3e2a76d8b0e5d0a      0t0  TCP 172.26.28.94:53638->lb-140-82-113-26-iad.github.com:https (ESTABLISHED)
Reqable 23521 USERNAME  184u  IPv4 0x1345d1ac37d5e1f1      0t0  TCP localhost:dynamid->localhost:55832 (CLOSED)
Reqable 23521 USERNAME  185u  IPv6 0xe238921c2ccb99cc      0t0  TCP [2400:da00:c0c1:ff17:6c08:b4ce:319e:1548]:55834->[2606:50c0:8003::154]:https (ESTABLISHED)
Reqable 23521 USERNAME  247u  IPv4 0xe8ebc08587804d92      0t0  TCP 172.26.28.94:dynamid->172.24.2.194:50323 (ESTABLISHED)
Reqable 23521 USERNAME  248u  IPv4 0xb3c07acb38c9d632      0t0  TCP 172.26.28.94:56209->172.26.28.94:http-alt (ESTABLISHED)
MegatronKing commented 2 weeks ago

非常感谢,内容很详细。这个问题我测试过挂机一段时间,但是一直没法复现,我再研究下。

mac 上在 /etc/hosts 配置了 127.0.0.1 example.com 后,在 Android 使用应用建立连接(好像是 VPN 模式)的情况下,无法通过 example.com:8080 访问到 127.0.0.1:8080

这个是正常的。手机VPN模式下,DNS是由手机去解析的,解析到IP之后,代理给电脑由电脑进行IP连接。所以电脑上配置 /etc/hosts肯定是无效的,应该要在手机上配置。