reqable-app icon indicating copy to clipboard operation
reqable-app copied to clipboard

[question] 问个日志错误的问题哇,想不清楚了

Open Alost opened this issue 1 year ago • 6 comments

背景:我有个安卓应用,内部是不是用系统dns的,是自己的https dns查ip的,对于Cloudflare的域名,Reqable抓不到包,直接连接断开, 10-11 14:21:43.280 3365 3422 E Caused by: 10-11 14:21:43.280 3365 3422 E 0: client error (Connect) 10-11 14:21:43.280 3365 3422 1: operation timed out

Reqable日志如下: 10-11 15:52:39.3440 [V][Netbare]: [889] Using https proxy protocol. 10-11 15:52:39.3441 [V][Netbare]: [889] [TCP] Connecting to 104.19.61.23:443 =====》真实ip,非Reqable代理ip 10-11 15:52:39.3443 [E][Netbare]: [890] Failed to detect application protocol! =====》注意这个 10-11 15:52:39.3446 [I][Netbare]: [890] TCP proxy session closed!

想问下 Failed to detect application protocol! 这个是指什么协议呢? http/https? http1/http2? 感觉不像后者,我试了http1也是不行的。

dns查询到的ip是有很多个的,104.19这个网段的都是,但是同时存在其他正常报文,不确定 Using https proxy protocol. 是否对应这些ip的 10-11 15:52:45.8042 [V][Netbare]: [926] [TCP] Connected 104.19.61.37:443 10-11 15:52:45.8298 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:45.8298 [V][Dart]: [Collaborative] Reveive a message from client: androidAppStackTraceReply 10-11 15:52:45.8307 [V][Dart]: [Collaborative] Reveive a message from client: androidAppStackTraceReply 10-11 15:52:45.9910 [V][Netbare]: [925] Using https proxy protocol. 10-11 15:52:45.9910 [V][Netbare]: [925] [TCP] Connecting to 104.19.61.38:443 10-11 15:52:46.0063 [V][Netbare]: [925] [TCP] Connected 104.19.61.38:443 10-11 15:52:46.0315 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:46.1910 [V][Netbare]: [927] Using https proxy protocol. 10-11 15:52:46.1911 [V][Netbare]: [927] [TCP] Connecting to 104.19.61.36:443 10-11 15:52:46.2066 [V][Netbare]: [927] [TCP] Connected 104.19.61.36:443 10-11 15:52:46.2302 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:46.3911 [V][Netbare]: [928] Using https proxy protocol. 10-11 15:52:46.3912 [V][Netbare]: [928] [TCP] Connecting to 104.19.61.35:443 10-11 15:52:46.4054 [V][Netbare]: [928] [TCP] Connected 104.19.61.35:443 10-11 15:52:46.4309 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:46.5916 [V][Netbare]: [924] Using https proxy protocol. 10-11 15:52:46.5917 [V][Netbare]: [924] [TCP] Connecting to 104.19.61.39:443 10-11 15:52:46.6151 [V][Netbare]: [924] [TCP] Connected 104.19.61.39:443 10-11 15:52:46.6344 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:46.7925 [V][Netbare]: [923] Using https proxy protocol. 10-11 15:52:46.7927 [V][Netbare]: [923] [TCP] Connecting to 104.19.61.40:443 10-11 15:52:46.7933 [E][Netbare]: [924] Failed to detect application protocol! 10-11 15:52:46.7935 [I][Netbare]: [924] TCP proxy session closed! 10-11 15:52:46.8063 [V][Netbare]: [923] [TCP] Connected 104.19.61.40:443 10-11 15:52:46.8340 [V][Dart]: [Collaborative] Reveive a message from client: mobileAppInfoReply 10-11 15:52:46.8349 [V][Dart]: [Collaborative] Reveive a message from client: androidAppStackTraceReply 10-11 15:52:46.9944 [V][Netbare]: [922] Using https proxy protocol.

做过的尝试: 用代理终端和开着Reqable在adb里去curl是正常的。 用系统dns是正常的,这里的区别是系统dns查到的是Reqable的代理ip,我自己查到的是真实ip,这个感觉是直接原因,但是我又测试一点,非Cloudflare的域名是正常的,日志如下: 10-11 15:52:37.3379 [V][Netbare]: [882] [TCP] Connected 167.235.178.84:443 =====》真实ip,非Reqable代理ip 10-11 15:52:37.3528 [V][Netbare]: [883] Using https proxy protocol. ====》这个协议?下面的流程是正常的 10-11 15:52:37.3534 [V][Netbare]: [881] [SSL] Resolving client hello... 10-11 15:52:37.3534 [V][Netbare]: [881] [SSL] Alpn offering: h2 10-11 15:52:37.3534 [V][Netbare]: [881] [SSL] Alpn offering: http/1.1

对比来看,感觉是Reqable分不清楚我的请求是http还是https,然后直接断开了,我代码上是对域名种类是不区分的,而且同时存在2种域名分别请求也试过,每种域名都有2个不同的例子,我研究了好久,实在搞不懂了。

我试过非协同模式也是一样连接直接断开的,我不知道 Reqable是如何判断我这个报文是http还是https的,我的知识告诉我,第一个报文是 tls client-hello报文就是https,否则就是http,我发http报文也是用的rust的 reqwest 框架统一发的,搞不清楚为啥对Cloudflare的域名产生区别了。

Alost avatar Oct 11 '25 08:10 Alost

@Alost 您好,很抱歉回复晚了。这个理论上和服务器IP或者域名没什么关系,像是手机端产生的问题(这个不是确定指你App有bug,也可能是Reqable这边的bug)。

正常流程下,App发出一个请求,被VPN转发到Reqable,Reqable会和远端服务器建立连接,然后Reqable会读取客户端的请求数据来判断你的访问协议是走HTTP还是HTTPS或者其他。

10-11 15:52:46.5916 [V][Netbare]: [924] Using https proxy protocol.
10-11 15:52:46.5917 [V][Netbare]: [924] [TCP] Connecting to 104.19.61.39:443
10-11 15:52:46.6151 [V][Netbare]: [924] [TCP] Connected 104.19.61.39:443

上面这一步表示正常和远端服务器建立连接了,但是接下来读取客户端的请求报错了,产生下面这个日志。

10-11 15:52:46.7933 [E][Netbare]: [924] Failed to detect application protocol!

正常情况下是读取到客户端的请求数据,判断出应用层的协议类型。

MegatronKing avatar Oct 16 '25 10:10 MegatronKing

再补充一下,读客户端请求报错,是Socket层面的,由于App和Reqable不是直接建立Socket连接的,而是通过VPN这个转发,所以哪里出错还是挺难猜测的。如果能提供个Demo APK来辅助分析可能会比较容易定位问题。

MegatronKing avatar Oct 16 '25 10:10 MegatronKing

我理解,我测试过自己请求DNS的话,如果是用UDP方式请求,那么后面的报文抓包都是正常的,如果是用 DoH 的 https 请求dns的话,CF域名的就连接不上,感觉Reqable还依赖了DNS,我也不知道啥原因,先不管了,谢谢!

Alost avatar Oct 16 '25 10:10 Alost

我理解,我测试过自己请求DNS的话,如果是用UDP方式请求,那么后面的报文抓包都是正常的,如果是用 DoH 的 https 请求dns的话,CF域名的就连接不上,感觉Reqable还依赖了DNS,我也不知道啥原因,先不管了,谢谢!

你是先用http dns先请求到你CF域名的IP,然后通过reqwest IP直连去建立连接发送请求的吗,这种情况下会出上面的问题?但是如果用reqwest通过域名连接发送请求就正常?

MegatronKing avatar Oct 16 '25 10:10 MegatronKing

不是,我是在创建 reqwest client 的时候通过 dns_resolver2 来自定义dns解析器的,然后dns解析器里可以根据参数选择用 udp or doh https or dot tls 去查询域名对应的ip。 如果用udp查询dns,则一切正常,如果用 doh https查询dns,则CF域名的出问题了,ip是能查到的,说明dns查询应该没问题。 差异其实在于,如果用udp,Reqable是很容易监听到的,但是用https的话,Reqable没做特殊处理就会忽略,所以我猜Reqable内部可能有依赖dns关系。 不知道这样说你能不能理解

Alost avatar Oct 16 '25 10:10 Alost

也可能是我环境有问题,中间设计环节太多了,单一方面不好分析的

Alost avatar Oct 16 '25 10:10 Alost