Defold-WebSocket (DEPRECATED)

I checked my server returns in the headers “binary” too. But crash happens anyway

even has time to accept the message, but breaks off

That is, with a handshake, everything is fine! But when receiving a message = crash

1 Like

I’ve released a new version of luasec with openssl compiled for arm-64: https://github.com/britzl/defold-luasec/releases/tag/1.1.0

3 Likes

Strange. @selimanac and @endel have you been able to connect from an HTML5 Defold client to a Colyseus server?

I just build tic-tac example as html5 and test it on my local environment. Seems like it is working. To be honest, I didn’t understand the problem here.

1 Like

The Colosseum transmits binary data. That is why it works. And I pass in all my projects = string (json), like most of the developers who use web sockets.

Is it possible to somehow choose other data types? Web socket capabilities are limited in this view.

my:

1 Like

Pleaaaaaase, add select type :sneezing_face:

I have exact same issue! Any way to fix it?

No :frowning:

Remind me again. What is the problem here? What do you mean by “type” in the context of a WebSocket?

Websockets can take two types, but in this implementation you can send/put only binary data.

In android / ios / simulator - two types
in hmtl5 - only binary! :frowning:

Really needed: STRING!

Can you provide some documentation? Is this the Sec-WebSocket-Protocol header?

In my example provided with defold-websocket I passed the wrong data to ws_protocol. I took a look at the code yesterday and made a minor change to handle this properly:

With this change all but the HTML5 platform allows you to define whatever value to Sec-WebSocket-Protocol in the second argument to self.ws:connect(url, [ws_protocol], [sslparams]).

In HTML5 builds the whole websocket setup is done by Emscripten in which case the Sec-WebSocket-Protocol is always binary. I have an idea to not use Emscripten and sockets and instead immediately use JavaScript to create the websocket.

The thing I do not understand still is why? I’m thinking that with the type set to binary you would be able to pass any kind of data. Strings are after all bytes right?

3 Likes

I thought so too, but it’s not. Socket breaks

It’s cool idea!
I worked with sockets on corona sdk in html including. It was done on pure JS

Is there a chance for me to play around and try to connect against a server where there’s a crash when sending and receiving data?

1 Like

Made for the test. Send any text and it returns in a second

wss://lost.webday.ru/britzl_test99

1 Like

I think here you can also test
http://websocket.org/echo.html

ws://demos.kaazing.com/echo – Binary
ws://echo.websocket.org – String

They also talk about the fact that there is a difference in data types.

1 Like

Not using emscripten for the HTML5 builds would be really good indeed. I’ve had some headaches by parsing multiple binary messages being delivered in a single “on_message” callback from the HTML5 builds a while back (it doesn’t happen on Desktop builds). Fortunately I’ve managed to work around that, but my workaround is a bit fragile.

2 Likes

Excuse me! Have you added two data types for HTML5? I would like to return to development

Please note that this extension is deprecated in favour of the new native WebSocket extension: Extension-websocket

I believe Colyseus and others have migrated to the new one.

Locking this topic.

2 Likes