Lua https 超时不起作用

1 https lua openwrt luasocket

我正在使用以下版本的 Lua 及其在 openWRT 环境中的数据包:

  • luasocket-2.0.2

  • luasec-0.4

  • lua-5.1.4

尝试使用超时进行https.request通话。尝试使用https.TIMEOUTwherelocal https = require("ssl.https")并且它永远不会超时。我尝试给出一个非常小的timeout(我知道我不会在那个时候得到答案并且互联网连接正常)我也尝试过一次https.request调用网络连接断开时。这是一个已知问题吗?或者我应该为此尝试其他方法。我可以猜测要么send/recieve是无限时间阻止它。

-Swapnel

cat*_*ell 5

设置超时ssl.https不起作用。您必须将其设置为socket.http

例如,如果您的代码如下所示:

local https = require "ssl.https"
https.TIMEOUT = 0.01
b, c, h = https.request("https://www.google.fr/")
Run Code Online (Sandbox Code Playgroud)

把它改成这样:

local http = require "socket.http"
local https = require "ssl.https"
http.TIMEOUT = 0.01
b, c, h = https.request("https://www.google.fr/")
Run Code Online (Sandbox Code Playgroud)