openresty / openresty/lua-resty-websocket
sending messages to already created websocket objects
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 523
- Forks
- 112
- Avg merge
- 1d 16m
- Merged PRs (30d)
- 2
Description
I have a list of websocket server objects that get created when client(s) call in on port A.
Another port, B listens for incoming http requests(no websockets here) on same server. The requirement is to send messages to websocket clients via already created websockets connections (on port A) based on requests on port B.
My initial hunch was just to test the created websocket object in different request contexts.
To start with, I saved the websocket server object in a global table variable. Requests on port B seem to have access to earlier saved websocket object. Tried sending text using this object through it resulted in error:
lua entry thread aborted: runtime error: ...r/openresty/1.13.6.1/lualib/resty/websocket/protocol.lua:320: bad request
stack traceback:
coroutine 0:
[C]: in function 'send'
...r/openresty/1.13.6.1/lualib/resty/websocket/protocol.lua:320: in function '_send_frame'
...lar/openresty/1.13.6.1/lualib/resty/websocket/server.lua:167: in function 'send_text'``
Any insights? I was going to try the ngx.shared.DICT next but wanted to check with you all. I am new to openresty and Lua
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported send_text failure in resty/websocket/server.lua and the bad request traceback from resty/websocket/protocol.lua. Read how the websocket object is used across requests on ports A and B, including the proposed ngx.shared.DICT approach. The issue does not define a concrete fix or completion test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100