Using websocket - getting multiple errors (SOLVED)


#1

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.


#2

Have you added the required dependencies to your project?


#3

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


#4

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?


#5

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.


#6

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.


#7

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


#8

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.


#9

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?


#10

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


#11

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.


#12

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.


#13

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!


#14

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


#15

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


#16

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.


#17

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.


#18

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!