Using websocket - getting multiple errors (SOLVED)

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.

1 Like

Have you added the required dependencies to your project?

The custom engine is built on our cloud server. It is not using your local machine for that.

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?

Those should be enough. I’m not in front of a computer for another week so I’m unable to assist.

It’s really strange with the mime package. It should be available on all platforms. I can’t recall that there are any conditionals for platforms.

I will try with an empty project and go from there. Maybe I messed with enough stuff to freak the project out.

I should refactor all the code anyway. I will keep you apprised.

Start by adding just defold-luasocket as a dependency and check that you have mime available.

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")

end

function update(self, dt)
self.ws:step()
end


My project file includes:

[project]
title = Crook2
dependencies = https://github.com/britzl/defold-websocket/archive/master.zip,https://github.com/britzl/defold-luasocket/archive/0.11.zip

So I think there’s something going on that’s beyond my pay grade.

Hmm, I see. I am unfortunately unable to assist for another week as I’m away on vacation. I’ll happily help once I’m back though.

Is that the exact error message? I get nothing at all when googling that. Which browser and os?

@dossy and @endel have you tried connecting to a Closeup server from a Defold HTML5 build?

1 Like

Hey @raul.carolus @britzl,

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.

1 Like

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.

2 Likes

I think I’m using the one under colyseus-defold. I’ll have to check at some point. I’ll try to make sure I get the right one in there.

I hope I can get this going, I really want to use this as it’s going to simplify a bunch of stuff for me!

2 Likes

Do you get the syscall 13 error when closing the websocket or at some other point?

1 Like

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.

1 Like

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.

2 Likes

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.

Thanks!

3 Likes