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

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

Open
zsh2517 opened this issue Jun 6, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@zsh2517
Copy link

zsh2517 commented Jun 6, 2024

问题描述

按照时间顺序

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

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

  • Reqable Android 断开连接重新连接 / 退出并重新启动,无变化
  • Reqable Mac 重新启动,可以正常使用(通常端口号会自动 +1,比如后面的测试是从 9000 加到了 9002 的监听端口)
  • lsof 查看 9002 端口,Reqable 正在监听;使用 tcping, curl 测试,表现为有发送无响应

复现方式

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

不过实际使用时,基本上每次打开并使用手机链接(主要是靠网络配置中设置代理,或者使用 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。这里暂不讨论

设备信息

提供代理的机器

  • Mac M2, OS: 14.5 (23F79)
  • Reqable 2.17.0 (92) (旧版 2.14.1 同样存在问题,刚升级成了 2.17.0,仍然可以复现)

被抓包的机器

  • Redmi k60, reqable App: 2.16.1,辅助服务 1.0.0,使用 VPN 模式
  • iPhone 12 mini, iOS 14.1,配置为系统代理

可能相似的问题

#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)
@zsh2517 zsh2517 added the bug Something isn't working label Jun 6, 2024
@MegatronKing
Copy link
Member

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

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肯定是无效的,应该要在手机上配置。

@poxxhub
Copy link

poxxhub commented Jul 24, 2024

遇到同样的问题,开启代理一段时间之后端口无法使用,只能电脑手机同步修改端口才可以继续使用
电脑:
MacBookPro M3pro, OS: 14.4
Reqable 2.20.0 (97)
手机
iPhone 12, iOS 17.5.1,系统代理

相同环境用Charles和Proxyman都没遇到这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants