Problem with websockets over https

Hi!

We have a problem connecting our game to the server via HTML5 when we use websockets.

Here are the extensions we use:

When we connect using ws://ws.domainname.com:2567

All is well - the connection is established. But this solution doesn’t work in browser, we get an error:

Mixed Content: The page at ‘https://game.domainname.com’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://ws.domainname.com:2567/matchmake/joinOrCreate/lobby’. This request has been blocked; the content must be served over HTTPS.

We tried to use wss instead of ws but at the connection we get an error:

ERROR:DLIB: mbedtls_ssl_handshake failed: Unknown error - -29184 (-0x7200)

ERROR:SCRIPT: HTTP request to ‘https://ws.domainname.com:2567/matchmake/joinOrCreate/lobby’ failed (http result: -1 socket result: -100)

We will be very happy. if you tell me how to solve this error.

Thank you!

This is a common problem, but easily solved by serving all content over http/ws or https/wss.

Can’t you also serve http://ws.domainname.com:2567/matchmake/joinOrCreate/lobby over a secure socket? And shouldn’t it be wss:// instead of http:// if it is an endpoint with a websocket server listening for websocket client connections?

1 Like

We only want to use https.

This is the code for how we connect to Colyseus:
BASE_CORE_URL = “wss://ws.domainname.com:2567”
remote.client = Colyseus.new(BASE_CORE_URL)

And after that I get the error:
ERROR:SCRIPT: HTTP request to ‘https://ws.domainname.com:2567/matchmake/joinOrCreate/lobby’ failed (http result: -1 socket result: -100)

I don’t understand. You mention that you are using WebSockets but the error is from a normal HTTP request:

Could you please test the Colyseus example that comes shipped with Colyseus and verify that it is working?

Perhaps @endel has some other suggestions?

1 Like

Ok i will make a simple project with this problem and post it here. Thanks!

My Project.zip (5.4 KB)
It’s a simple project - here’s how it works. Thank you!

There was a typo in the URL in the test project but once that was fixed I was able to do some tests:

  • I tested from my local machine with a macOS build first - The connection to wss://stagews.chimerakingdom.io:2567 resulted in:
ERROR:DLIB: SSLSocket mbedtls_ssl_handshake: -29184 - 
ERROR:SCRIPT: HTTP request to 'https://stagews.chimerakingdom.io:2567/matchmake/joinOrCreate/lobby' failed (http result: -1  socket result: -1000)
DEBUG:SCRIPT: offline

It doesn’t seem like there’s anything responding on https?

  • Next I tested with ws://stagews.chimerakingdom.io:2567 on macOS:
DEBUG:SCRIPT: websocket connected 
DEBUG:SCRIPT: success
  • The same build worked when doing Project->Build HTML5. The webpage that is launched is http:// and the server URL is also http:// so there’s no cross origin problems.

  • I finally tested Project->Build HTML5 using wss://stagews.chimerakingdom.io:2567 but as expected I got:

Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
dmloader.js:507 DEBUG:SCRIPT: offline

Conclusion: You need to fix the https connectivity issue first before testing anything else.

4 Likes