Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么会报错"lua tcp socket read timed out" #33

Open
lanss315425 opened this issue Dec 26, 2017 · 1 comment
Open

为什么会报错"lua tcp socket read timed out" #33

lanss315425 opened this issue Dec 26, 2017 · 1 comment

Comments

@lanss315425
Copy link

lanss315425 commented Dec 26, 2017

--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

@lanss315425
Copy link
Author

我这样做经常出现这样的错误,这是为什么呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant