I’m having several issues using websockets (with colyseus, but the errors are websockets related).
When I run on Android, I get the error: “/websocket/tools.lua:162: attempt to index upvalue ‘mime’ (a nil value)” In my project I see that mime is added as a plugin - with the socket library. I don’t know how to fix this error.
Trying to run on linux native, it gives me a build error with luasec: “/luasec/include/openssl/x509.h Undefined reference to OPENSSL_sk_new_null” I assume this has something to do with the openssl dev libraries, but I have those installed on my machine.
Running in HTML5 works, but crashes when I try to switch rooms with colyseus - it disconnects the websocket when leaving a room. I get the error: unsupported socketcall syscall 13 during the disconnect process.
So I’m having lots of trouble with this and am starting to get discouraged. Any help would be wonderful.
I did add the required libraries to the project . I added the colyseus stuff, then the luasec, websocket, and the other (luasocket? I’m not infront of my computer) one that was listed. Were there further requirements?
There definitely is something going on between the websockets and a colyseus server. I made a new defold project and included the luasec, luasocket, and defold-websocket requirements. I ran it as HTML5. Then I simply open a websocket to my colyseus server (which works fine using the colyseus JS library), and close it. It crashes with the “unsupported syscall 13” error.
my main.script file:
local client_async = require “websocket.client_async”
function init(self)
self.ws = client_async()
self.ws:on_connected(function(ok, err)
if ok then
print("Connected")
self.ws:close()
else
print("Unable to connect", err)
end
end)
self.ws:on_disconnected(function()
print("Disconnected")
end)
self.ws:on_message(function(message)
print("Received message", message)
end)
self.ws:connect("ws://localhost:2567")
So far I haven’t had any issue on Android. Me and @BunBunBun are successfully building a game for Android/iOS/Browser using it.
The unsupported syscall 13 indeed happens for us on this same scenario. It sounds like an emscripten-related thing. Not sure how to fix it. Whenever the WebSocket connection is closed, this error happens (again, only on HTML5/emscripten). Confirmed this issue on Chrome and Firefox, probably happens everywhere.
I didn’t have a chance to build for Linux yet, so I can’t really tell if it works there.
Hey @raul.carolus, which luasec dependency are you using? I’ve just noticed the right one is described under @britzl’s websocket project, the one described on colyseus-defold was outdated. I’ve just updated to the correct one in the README.
Hey @britzl, only when the websocket connection is closed. It doesn’t matter who initiated the disconnection, if client tries to force disconnection, or the server does it - the same error can be observed
Ok. Thanks. I saw now from the github issue that it’s actually “unsupported socketcall syscall 13” and I found that 13 is SYS_SHUTDOWN so it definitely relates to the closing of the socket using emscripten. Not sure if there’s a solution. Might be an emscripten bug that’s solved in a newer version. We plan to upgrade to a newer version at some point.
I’ve changed so that no call to shutdown() is made when running on HTML5. Not even sure a call to shutdown() is needed since a call to close() happens on the next line.
The changes that were made since I posted the original thread appear to have worked. I verified my project settings and updated libraries. It all appears to work now. I am no longer getting the errors I was and my code works further than it did.