0wQ / air724ug-forwarder

Air724UG 短信转发 & 来电通知 & 语音信箱
MIT License
289 stars 39 forks source link

Air724UG配置了brak,请求http总是失败 #14

Closed hhdebb closed 1 year ago

hhdebb commented 1 year ago

请求部分日志如下:

[2023-06-06 09:40:25.540] [I]-[util_notify.add] 添加到消息队列, 当前队列长度: 1
[2023-06-06 09:40:25.617] [I]-[ntpSync] 时间正常, 无需同步
[2023-06-06 09:40:25.617] [I]-[util_notify.poll] 轮询消息队列中, 当前队列长度: 1
[2023-06-06 09:40:25.617] [I]-[util_notify.send] 发送通知 bark
[2023-06-06 09:40:25.617] [I]-[ril.sendat] AT+RFTEMPERATURE?
[2023-06-06 09:40:25.617] [I]-[util_notify] POST https://xxx.com/send/your_key
[2023-06-06 09:40:25.617] [I]-[util_http.fetch] 开始请求 id: http_c1_r7210
[2023-06-06 09:40:25.617] [I]-[http path] /send/your_key
[2023-06-06 09:40:25.617] [I]-[socket:connect-coreid,prot,addr,port,cert,timeout] 0 TCPSSL xxx.com 443 nil 30
[2023-06-06 09:40:25.617] [I]-[ril.proatc] +RFTEMPERATURE: 39.84
[2023-06-06 09:40:25.617] [I]-[ril.proatc] OK
[2023-06-06 09:40:26.057] [I]-[socket:on_response:] 0 SOCKET_CONNECT 1
[2023-06-06 09:40:26.057] [I]-[socket:connect: connect fail] RESPONSE
[2023-06-06 09:40:26.057] [E]-[http.response] false connect fail
[2023-06-06 09:40:26.057] [I]-[socket:sock_close] nil
[2023-06-06 09:40:26.057] [I]-[util_http.fetch] 请求结束 id: http_c1_r7210
[2023-06-06 09:40:26.057] [I]-[util_notify.send] 发送通知失败, 无需重发 code: -99 body: 
hhdebb commented 1 year ago

@0wQ

0wQ commented 1 year ago

有试过换 http 吗

naizhao commented 1 year ago

证书没配置好,是不是用了自签名证书或者缺少证书中级根

hhdebb commented 1 year ago

证书没配置好,是不是用了自签名证书或者缺少证书中级根

域名证书是Letsencrypt,但是我看代码中请求http.request(method, url, nil, headers, body, timeout, callback),证书是忽略的,第三个参数

hhdebb commented 1 year ago

有试过换 http 吗

用https://api.day.app,没问题的。我自己又试了下http倒是可以了请求成功了,看来问题出在证书上面

0wQ commented 1 year ago

检查一下服务器 TLS 最低版本是不是 TLSv1.3 Air724UG 好像最高支持到 1.2

hhdebb commented 1 year ago

检查一下服务器 TLS 最低版本是不是 TLSv1.3 Air724UG 好像最高支持到 1.2

检查了也不是1.3,暂时懒得折腾了,http先用着吧。感谢解惑

dumpmemory commented 1 year ago

cloudflare 是不是开了 tlsv1.3 关掉就行

panpaul commented 9 months ago

我遇到了类似的错误,除了已经提到的不支持 TLSv1.3 外,还有一点是:LuatTools 下载时不要勾选 添加默认lib,而是手动导入作者提供的所有脚本

合宙提供的脚本(截至 2024.01.03)在请求 HTTPS 时如果没有配置客户端证书,则在 TLS 握手时不会发送 server_name 扩展,目前绝大多数开启 strictSni 的服务器会直接断开连接。如果需要使用新版本的官方脚本,需要手动修改 hostNameFlag 参数:

--- socket4G.lua
+++ socket4G.lua
@@ -161,7 +161,7 @@
     elseif self.protocol == 'TCPSSL' then
         local cert = {hostName = address}
         local insist = 1
-        local hostNameFlag = 0
+        local hostNameFlag = 1
         if self.cert then
             if self.cert.caCert then
                 if self.cert.caCert:sub(1, 1) ~= "/" then self.cert.caCert = "/lua/" .. self.cert.caCert end

或者像作者一样直接将 socket_connect_fnc 的最后一个参数固定为 1

https://github.com/0wQ/air724ug-forwarder/blob/d1fd02128141db72fafd8d8805b2883ce6dc206c/script/lib/socket4G.lua#L155