Opening a websocket to a host which isn't online deadlocks
Mehgugs opened this issue · comments
I was testing a websocket client for a service I'm hosting locally right now. I forgot to start said service before testing my client and noticed no errors, but that the lua process was using a lot of CPU resources.
Here is my connect function:
function connect(node)
node.socket = websocket.new_from_uri(node.config.wss)
node.socket.request.headers:upsert("user-agent", USER_AGENT)
node.socket.request.headers:upsert("authorization", node.config.password)
node.socket.request.headers:upsert("num-shards", tostring(tointeger(node.link.shards)))
node.socket.request.headers:upsert("user-id", tostring(node.link.user_id))
logger.info("%s will now connect", node)
local success, str, err = node.socket:connect(3) --- This line blocks the coroutine forever and cqueues starts to use a lot of resources
if not success then -- expected it to reach here
return logger.error("%s had an error while connecting (%s - %q, %q)", node, errno[err], errno.strerror(err), str or "")
else
node.connected = true
node.link.loop:wrap(messages, node)
logger.info("%s connected", node)
end
end
In this scenario I would expect an ECONNREFUSED.
I would note that my lua process is being run currently from a wsl session while I test locally and that
the service is hosted "outside" on windows.
This times out for me after 3 seconds:
websocket = require "http.websocket";
r=websocket.new_from_uri("wss://example.com:9999");
r:connect(3);
Try it with the local loopback a la:
websocket = require "http.websocket";
r=websocket.new_from_uri("ws://127.0.0.1:9999");
r:connect(3)
Seems it only happens for me when it's localhost
Okay i've looked more closely and it seems to be specific to WSL (windows subsytem for linux). You can close this but maybe a note on the cqueues repo about this platform having some issues might be a good idea?
Okay i've looked more closely and it seems to be specific to WSL (windows subsytem for linux). You can close this but maybe a note on the cqueues repo about this platform having some issues might be a good idea?
Please do so :)
Note that I have no idea how I'd debug a WSL-specific issue...