From 7240de08a9ffc161480daf17b37e654face25ee5 Mon Sep 17 00:00:00 2001 From: zixun Date: Sun, 21 Jul 2019 16:57:50 +0800 Subject: [PATCH] use sockethelper connect --- lualib/http/websocket.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lualib/http/websocket.lua b/lualib/http/websocket.lua index 0da38c3d..e62ee9fd 100755 --- a/lualib/http/websocket.lua +++ b/lualib/http/websocket.lua @@ -368,7 +368,7 @@ function M.accept(socket_id, handle, protocol) end -function M.connect(url, header) +function M.connect(url, header, timeout) local protocol, host, uri = string.match(url, "^(wss?)://([^/]+)(.*)$") if protocol ~= "wss" and protocol ~= "ws" then error(string.format("invalid protocol: %s", protocol)) @@ -382,8 +382,7 @@ function M.connect(url, header) end uri = uri == "" and "/" or uri - local socket_id = socket.open(host_name, host_port) - assert(socket_id) + local socket_id = sockethelper.connect(host_name, host_port, timeout) local ws_obj = _new_client_ws(socket_id, protocol) write_handshake(ws_obj, host_name, uri, header) return socket_id