lipp / lipp/lua-websockets

wss client connect error

Open
#103 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
419
Forks
117
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the wss connection using the example in the issue, then inspect websocket/sync.lua around line 131 and the failing ssl.lua:120 call. Trace how the SSL context is created for wss versus ws and compare the available connection setup. Done means the reported wss client error is understood and a verified correction or required setup is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.