When using HTTPS calls In Edge drivers, it stops working after a number (~250) of calls. Probably the client sockets aren’t closed properly. Seems to be or bug in ssl.https or have I missed a parameter that can solve this issue?
(HTTP doesn’t seem to have this issue, only HTTPS)
Test case to reproduce the issue:
local https = require('ssl.https')
local req_num = 1
for i=1, 256 do
local res = {}
local body, code, headers, status = https.request {
method = 'GET',
url = 'https://IP',
data = '',
protocol = "any",
options = {"all"},
verify = "none",
sink=ltn12.sink.table(res)
}
print('REQ ', req_num, body, code, status)
req_num = req_num + 1
end
@erickv
The output from the code above will not give any error information.
But If run the code below (that should have exactly same functionality), the output is as follow:
local socket = require('socket')
local http = require('socket.http')
local ltn12 = require('ltn12')
local ssl = require('ssl')
driver:call_with_delay(1, function ()
local try = socket.try
function create()
local t = {c = try(socket.tcp())}
function idx (tbl, key)
return function (prxy, ...)
local c = prxy.c
return c[key](c,...)
end
end
function t:connect(host, port)
try(self.c:connect(host, port))
self.c = try(ssl.wrap(self.c,params))
self.c:sni(host)
try(self.c:dohandshake())
return 1
end
return setmetatable(t, {__index = idx})
end
for i=1, 256 do
local res = {}
local b, c, h = http.request {
url='https://192.X.X.X',
create = create,
sink=ltn12.sink.table(res),
}
print(b, c, h, i)
end
end, 'TEST START TIMER')
This is an issue we noticed internally too. The fix has been written, but I’m not sure where it is in the release pipeline. I’ll see if I can track that down real quick.
Actually the fix is in the beta release that just went out this morning: Hub Firmware 0.40.X Beta
It was a leak for TLS sockets in general. Though there’s still currently a bug that means the TLS sockets count double against the limit, but once close both of those are uncounted, but you’ll have an effective limit of 128 TLS sockets for the moment.
And thank you for the bug report with a minimal reproduction. Getting those is so immensely helpful.