With an empty clean project, and this code based on the example page:
local client_async = require "websocket.client_async"
self.ws = client_async()
if ok then
print("Unable to connect", err)
function update(self, dt)
It prints the message properly if the server is running. But if the server is not running, the “Unable to connect” does not get printed.
I also tried Colyseus, and it’s the same thing. The “on error” event there also doesn’t get triggered.
I tried it on the latest editor 1.2.142, but I’ve never been successful in older versions either. I also tried html5 build, I do get a websocket error there.
However, this error is not captured in code (i.e. can’t connect error doesn’t even get printed in the console).
How do I capture this connection refused properly in code, so I can display an error message properly? Potential workaround is to have a timeout e.g. if after 2 seconds I am still not connected, then I can assume something is wrong with the connection. But I am hoping this is something the extension is capturing properly, and I just don’t know how to make it work.