openresty / openresty/lua-nginx-module
Persistent connection support for `raw` sockets (ngx.req.socket(true))
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
It seems that OpenResty doesn't support persistent connections when handling requests using ngx.req.socket(true). If one runs the code from test#15:
https://github.com/openresty/lua-nginx-module/blob/master/t/116-raw-req-socket.t#L785
Note: There is a bug with this test as err is used as both a variable and function name so one needs to be changed (e.g. sed 's/err(/errfn(/g' 116-raw-req-socket.t)
It can be seen that if a client sends more than one request (with header Connection: keep-alive) down the same TCP connection only the first one is acted on. It works fine if the client closes the connection and opens a new each time but this is inefficient. Also lua scripts can clearly handle persistent connections when using non-raw socket ngx.req.socket(). I'm wondering if there's anything missing from that test code to support persistent connections or if OpenResty (tested v1.13.6.2 & v1.15.8.1) doesn't support it? Support for it would be good.
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 test/116-raw-req-socket.t around test 15 and reproduce the behavior after correcting the err name collision described in the issue. Compare repeated requests over one keep-alive TCP connection with the non-raw ngx.req.socket() case, then trace the raw-socket handling involved. Done means the test demonstrates that multiple requests on the same connection are handled correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100