为什么会报错"lua tcp socket read timed out"
--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
我这样做经常出现这样的错误,这是为什么呢