openresty / openresty/lua-nginx-module

how to use receiveany?

Open
#1,773 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

local sock = ngx.req.socket(true)

local maxlen = 16*1024
local data = nil
local err = nil
local receivenum = 0

sock:settimeout(1900)

sock:settimeouts(2000, 2000, 2000) -- one second timeout for connect/read/write
local data, err = sock:receiveany(1024) -- read any data, at most 10K
if not data then
ngx.say("failed to read any data: ", err)
return
end
ngx.log(ngx.ERR,"read data:"..tostring(#data))
ngx.say("successfully read: ", data)

when i use receiveany API ,i got error:
2020/08/24 09:17:51 [error] 17713#0: *5 lua entry thread aborted: runtime error: /usr/local/nginx/conf/receiveany.lua:13: attempt to call method 'receiveany' (a nil value)

i want to know how can i use receiveany API ?

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

Start with the receiveany.lua example and the ngx.req.socket call shown in the issue, then check the NGINX/OpenResty module version and the documented socket methods. Done means documenting or reproducing the supported way to invoke receiveany and explaining the nil-method error.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, nginx
Domain
api, backend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.