admin管理员组

文章数量:1123046

I am using LUASocket and lua-sec along with FreeSWITCH to upload recorded voicemails to a NodeJS application. I'm not sure why, but intermittently the connection blocks indefinitely, and sometimes the uploads of <1MB files take 2~3 minutes (figuring out why is not my issue right now). I've tried setting timeouts at the http and https level (as can be seen in the code below) but this doesn't seem to be effective at all.

multipart-post is from here

Lua version is 5.2, FreeSWITCH version is 1.10.12

http = require "socket.http"
https = require "ssl.https"
mp_post = require "resources.multipart-post"

https.TIMEOUT = 5
http.TIMEOUT = 5

arg_file = argv[1]

local file_to_upload = io.open(arg_file, "r")
local file_length = file_to_upload:seek("end")
file_to_upload:seek("set", 0)

local rq = mp_post.gen_request({
    file = {
        name = arg_file,
        data = file_to_upload,
        len = file_length
    },
    mailbox_id = tostring(arg_mailbox_id)
})

rq.url = ";
rq.headers["Authorization"] = "Bearer <auth_token>"
rq.sink = ltn12.sink.table(api_response)

r, code, h, s = https.request(rq)   <--- This blocks indefinitely

Below this code block I have handling to control what happens if the upload times out, but it is never hit unless I set the values to 0.001

I see that there are 2 timeout modes, "b" and "t", "t" being for timeout control for the entire operation. The include for socket.http and ssl.https default to "b" mode, so I edited the LUA include files for both modules to change to "t" mode, and this also had no effect.

How do I force the upload to not take more than 5 seconds, so that I can play back hold music to the caller and retry the upload before they hang up from the silence?

本文标签: freeswitchLuasocket and luasec HTTPS request not honoring set timeoutStack Overflow