PING causes receive() problems
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 419
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
A bit surprising, this is _not_ about #14. I don't care about "proper" implementation of ping/pong but am having problems because the ws server (which is beyond my control) sends a ping on connect and the client on my side reads 1 byte too many and the frames on my side got royally screwed up from there on.
The problem is around here: https://github.com/lipp/lua-websockets/blob/master/src/websocket/sync.lua#L14
The first chunk read apparently is always of size 3 - but it turns out PING is a frame of only 2 bytes.
On example i tracked with wireshark, the first chunk read is "89 00 82", which gets returned to me as an empty message (which is fine by me) - however turns out the PING is actually "89 00" and the 82 is part of the next frame "82 0b ..." (11 byte binary frame). Because 82 was mis-read, the 2nd frame turns into "0b ..." and everything goes downhill afterwards.
Seems that simply changing that line to `bytes = 2` might be okay, given a quick skim at frame.decode() - but is that so?
ps. also `bytes = 2` on line 60
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 at src/websocket/sync.lua lines 14 and 60, then read the related frame.decode() handling. Reproduce the reported sequence where a two-byte PING is followed by an 11-byte binary frame, and verify that reads preserve both frame boundaries without consuming the next frame's first byte.
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
- Clearly specified
- Newbie friendliness
- 45/100