You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function testSSL()
local client = ws.client.sync({timeout=2})
local ok,err = client:connect("wss://echo.websocket.org/")
if not ok then
const.debug_print('could not connect', err);
end
local ok = client:send("Hello, World");
if ok then
print('msg sent')
else
print('connection closed')
end
local message,opcode = client:receive()
if message then
print('msg',message,opcode)
else
print('connection closed')
end
client:close()
end
testSSL()
------------------the error -------------------------------
lua: /usr/local/share/lua/5.1/ssl.lua:120: bad argument #1 to 'create' (SSL:Context expected, got nil)
stack traceback:
[C]: in function 'create'
/usr/local/share/lua/5.1/ssl.lua:120: in function 'wrap'
./websocket/sync.lua:131: in function 'connect'
websockHandle.lua:99: in function 'testSSL'
websockHandle.lua:122: in main chunk
[C]: ?
If I use ws client the function works right, what's the problem?
The text was updated successfully, but these errors were encountered:
I find the problem, the connect params are necessary.
--- add this -------
local ssl = {
mode = "client",
protocol = "tlsv1_2",
verify = "none",
options = "all",
}
local client = ws.client.sync({timeout=2})
local ok,err = client:connect("wss://echo.websocket.org/",'echo', ssl)
function testSSL()
local client = ws.client.sync({timeout=2})
local ok,err = client:connect("wss://echo.websocket.org/")
if not ok then
const.debug_print('could not connect', err);
end
local ok = client:send("Hello, World");
if ok then
print('msg sent')
else
print('connection closed')
end
local message,opcode = client:receive()
if message then
print('msg',message,opcode)
else
print('connection closed')
end
client:close()
end
testSSL()
------------------the error -------------------------------
lua: /usr/local/share/lua/5.1/ssl.lua:120: bad argument #1 to 'create' (SSL:Context expected, got nil)
stack traceback:
[C]: in function 'create'
/usr/local/share/lua/5.1/ssl.lua:120: in function 'wrap'
./websocket/sync.lua:131: in function 'connect'
websockHandle.lua:99: in function 'testSSL'
websockHandle.lua:122: in main chunk
[C]: ?
If I use ws client the function works right, what's the problem?
The text was updated successfully, but these errors were encountered: