1

我正在使用以下版本的 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

4

1 回答 1

5

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

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

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

将其更改为:

local http = require "socket.http"
local https = require "ssl.https"
http.TIMEOUT = 0.01
b, c, h = https.request("https://www.google.fr/")
于 2013-11-25T14:25:38.687 回答