【问题标题】:Lua https timeout is not workingLua https超时不起作用
【发布时间】:2014-06-18 04:49:48
【问题描述】:

我在 openWRT 环境中使用以下版本的 Lua 和它的数据包:

  • luasocket-2.0.2

  • luasec-0.4

  • lua-5.1.4

尝试对https.request 调用使用超时。尝试使用 https.TIMEOUT where local https = require("ssl.https") 并且它永远不会超时。我尝试给出一个非常小的timeout(我知道在那段时间我不会得到答案并且互联网连接正常)我也尝试过在调用https.request 时断开网络连接。这是一个已知问题吗?还是我应该为此尝试其他方法。我可以猜到send/recieve 会无限期地阻止它。

-Swapnel

【问题讨论】:

  • 如果您能提供完整的代码示例,那就太好了。不是wall of text manner。更容易阅读和理解您的问题:)

标签: https lua openwrt luasocket


【解决方案1】:

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/")

【讨论】:

    猜你喜欢
    • 2012-10-09
    • 2012-10-27
    • 2014-06-27
    • 2017-08-07
    • 2018-12-27
    • 2012-05-15
    • 2011-02-21
    • 1970-01-01
    • 2011-09-09
    相关资源
    最近更新 更多