Defold-WebSocket (DEPRECATED)

Which versions of dependencies are you using?
Could you please test the attached project
SocketTest.zip (1.5 KB)

1 Like

My dependencies:
defold6

I just tried your test project. Same results. I tried on another Windows 10 PC, and still not getting the refused connection event. I can connect fine though.

I just tried this on a Mac, and yes the refused connection event gets triggered there! In fact, even the disconnection event is ok. Could this be a Windows issue then? Anyone else can confirm this please?

However, I tried the html5 build, and even the Mac is having the same issues. Tried with both Safari and Chrome. Does this work for you in html5 build on a Mac?

Thanks for the help.

1 Like

In summary, here’s what I am getting.

On Windows 10, tested on 2 computers:
Server not running - I can NOT catch a connection refused error, both from the editor and html5 builds.
Server running - I can NOT catch the disconnection event from the editor, on html5 build it is OK.

On a Mac:
Server not running - I can catch a connection refused error from the editor, but NOT from the html5 build.
Server running - I can catch the disconnection event, both from the editor and html5 builds.

1 Like

Looks like there is a serious problem. Unfortunately I don’t have a Windows right now.
But I believe @britzl can help us out?

There’s different implementations for HTML5 and desktop builds so there’s no surprise that you might see different behaviours. Can you please open a ticket on GitHub in the Defold-Websocket project and I’ll take a look? Thanks.

1 Like

@britzl Hello, thanks for the great work you’ve been done!

But I have some troubles when trying to compile websocket based app. Desktop(Mac) version builds fine, but I can not build html5 version: I see this message as a result: https://monosnap.com/file/5MO1PEdFRZKqFNMX2OwMQ5RCcWfQ8x#

I’m using simple tutorial side scroller + these libs:

  • Websocket
  • luasocket
  • luasec

Screenshot of dependencies: https://monosnap.com/file/D3slZmiO0OWFtqzqhYqITIkvDKnodA
My project: https://github.com/semeyon/tutorial-side-scroller

Am I doing something in the wrong way?

Sounds like a corrupt dependency download. Could you please try to delete the .internal folder of your project, then do Fetch Libraries, and try to build again?

2 Likes

Thanks a lot! That helped!

2 Likes

Collective mind! I ask you for help! :slight_smile:
How to connect to wss: //, but to work on all platforms?

error:
"DEBUG:SCRIPT: Unable to connect /luasec/ssl.lua:120: bad argument #1 to ‘create’ (SSL:Context expected, got nil)

Registered luasec Extension"

There were some changes recently to SSL I think?

Which platforms is it not working on?

1 Like

I did try the example from defold-websocket and it didn’t crash on desktop or HTML5.

I try in the simulator in Mac OS
in a new project

15

Ok, so you tested in the iOS Simulator? I haven’t tried that…

not iOS, this is a simulator Defold in macos

Ok, I did the same and it works. Can you please clone this project, open it and run and click the connect buttons:

If you test for a clone, then everything is ok.
But the experiment will not be clean, as the code is proposed to be used differently, through Dependencies

Here, I specifically created a clean project for the test.
According to your instructions

https://drive.google.com/open?id=1kIdKxoUF0brj1Xy1xVhhb33x_Gcvj2Ev

I’ll take a look later. Thanks.

I can’t recall having this specific error, but I remember having to use this configuration to be able to connect via WSS:

local endpoint = "wss://your-endpoint"
local ssl_params = nil

if string.find(endpoint, "wss://") ~= nil then
  ssl_params = {
    mode = "client",
    protocol = "tlsv1_2",
    verify = "none",
    options = "all",
  }
end

ws:connect(endpoint, nil, ssl_params)
1 Like

As @endel points out you need to pass SSL Parameters when connecting using wss:// as protocol.

2 Likes