Lua https超时无效 [英] Lua https timeout is not working
问题描述
我正在使用以下版本的Lua及其在openWRT环境中的数据包:
I am using following versions of Lua and it's packets on openWRT environment:
-
luasocket-2.0.2
luasocket-2.0.2
luasec-0.4
luasec-0.4
lua-5.1.4
lua-5.1.4
尝试使用超时进行 https.request
调用。尝试使用 https.TIMEOUT
其中本地https = require(ssl.https)
并且它永远不会超时。我尝试给出一个非常小的超时
(我知道在那段时间我不会得到答案,互联网连接也没关系)我也试过当网络连接断开一次<$调用c $ c> https.request 。这是一个已知的问题吗?或者我会为此尝试别的东西。我可以猜测发送/接收
是无限期阻止它。
Trying to use timeout for a https.request
call. Tried using https.TIMEOUT
where local https = require("ssl.https")
and it never time outs. I tried giving a very small timeout
(I know that I won't get answer in that time and internet connection is OK) also I tried when net connection is disconnected once https.request
is called. Is it a known issue? or shall I try something else for this. I can guess either send/recieve
is blocking it for infinite time.
-Swapnel
推荐答案
在 ssl.https
上设置超时不起作用。你必须在 socket.http
上设置它。
Setting the timeout on ssl.https
does not work. You have to set it on socket.http
.
例如,如果你的代码是这样的:
For instance, if your code looks like this:
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/")
这篇关于Lua https超时无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!