openresty / openresty/lua-resty-websocket
为什么会报错"lua tcp socket read timed out"
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 523
- Forks
- 112
- Avg merge
- 1d 16m
- Merged PRs (30d)
- 2
Description
--config.session.timeout等于 60秒
local wb, err = server:new{ timeout = config.session.timeout, -- in milliseconds
max_payload_len = 65535,
}
if not wb then
ngx.log(ngx.ERR, "failed to new websocket: ", err)
return ngx.exit(444)
end
wb:set_timeout(config.session.timeout)
while true do
local data, typ, err = wb:recv_frame()
if wb.fatal then
--ngx.log(ngx.ERR, "failed to receive frame: ", err)
break
end
if not data and not typ then
ngx.log(ngx.INFO,"------------------------"..tostring(data)..","..tostring(typ)..","..tostring(err))
break
end
if not data then
local bytes, err = wb:send_ping()
if not bytes then
ngx.log(ngx.ERR, "failed to send ping: ", err)
end
elseif typ == "close" then
break
elseif typ == "ping" then
ngx.log(ngx.INFO,"------------rec ping:send pong")
local bytes, err = wb:send_pong()
if not bytes then
ngx.log(ngx.ERR, "failed to send pong: ", err)
break
end
elseif typ == "pong" then
ngx.log(ngx.INFO,"------------rec pong")
elseif typ == "text" then
ngx.log(ngx.INFO,"receive: "..tostring(data))
local res = resolve.doresolve(M,data)
if res then
--log.err("----------response:"..tostring(res)..",req:"..tostring(data))
if dosend(res)==0 then
break
end
end
end
end
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
No repository file or test is named. Start by tracing the timeout configuration passed to server:new and wb:set_timeout, then follow the wb:recv_frame loop and its error logging. Done means the cause of the timeout is identified and the issue includes a reproducible explanation or a confirmed corrective change.
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
- 25/100