Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wss client connect error #103

Open
mxinglee opened this issue Nov 21, 2016 · 1 comment
Open

wss client connect error #103

mxinglee opened this issue Nov 21, 2016 · 1 comment

Comments

@mxinglee
Copy link

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?

@mxinglee
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant