Lua https 超时不起作用 [英] Lua https timeout is not working

查看:25
本文介绍了Lua https 超时不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

lua-5.1.4

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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆