Open mxinglee opened 7 years ago
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)
This issue should be closed
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
If I use ws client the function works right, what's the problem?