openresty/lua-resty-websocket

Http链接重复利用给websocket时的错误

bazhi opened this issue · 1 comments

bazhi commented

websocekt/client.lua

local count, err = sock:getreusedtimes()
if not count then
return nil, "failed to get reused times: " .. err
end
if count > 0 then
-- being a reused connection (must have done handshake)
return 1
end

-- do the websocket handshake:

当一个http链接关闭之后,如果这个http链接,被websocket链接从链接池里面取出来时,则这个链接的reusedtimes时大于0的,然后这个链接不会被handshake。

@bazhi Please, do not use Chinese here. This place is considered English only. If you really want to use Chinese, please join and post to the openresty (Chinese) mailing list instead. Please see https://openresty.org/en/community.html Thanks for your cooperation.

Regarding to your question, it is wrong to do repeated websocket handshakes on a connection that has already done websocket handshake.