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!
britzl
June 2, 2022, 11:32am
2
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)
britzl
June 2, 2022, 12:49pm
4
Alexandr_Chizhevskiy:
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:
if (dmMessage::RESULT_OK != dmMessage::Post(0, requester, dmHttpDDF::HttpResponse::m_DDFHash, userdata1, userdata2, (uintptr_t) dmHttpDDF::HttpResponse::m_DDFDescriptor, &resp, sizeof(resp), MessageDestroyCallback) )
{
free((void*) resp.m_Headers);
free((void*) resp.m_Response);
dmLogWarning("Failed to return http-response. Requester deleted?");
}
}
static const char* FindHeader(Worker* worker, const char* header, char* buffer, uint32_t buffer_length)
{
// Headers are either 0, of a list of strings "header1: value\nheader2: value\n"
const char* current = (const char*)worker->m_Request->m_Headers;
const char* headers_end = current + worker->m_Request->m_HeadersLength;
while (current < headers_end)
{
const char* end = strchr(current, '\n');
uint32_t length = end - current;
if (strstr(current, header) == current)
{
if (length < buffer_length)
{
Could you please test the Colyseus example that comes shipped with Colyseus and verify that it is working?
⚔ Colyseus SDK for Defold Engine
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