HTML5 (Networking) Trouble Connecting HTML5 Game to Server Program

Mookal

Member
I'm working on a game that's meant to run in browsers and on mobile devices. It allows players to connect to a server program that I made in GMS.
Pretty much everything works perfectly; I can export builds of the client program for Android and Windows (for testing purposes) that can connect from outside networks and interact with the server. The HTML5 client works too, when I test it from GameMaker, but when I build it and push it to a web server (I use Neocities to host my websites), it's no longer able to connect.

A friend of mine (who is far more experienced than me with networking) tried hosting the HTML5 client themselves, and found that it was unable to connect because the page was loaded on HTTPS, but it was attempting to connect to the server through HTTP (secure page trying to open an unsecure WebSocket connection). Neocities pages also have secure connections, so we suspect this is the issue.
1616692121696.png

To me, it's looking like this is something that can only be fixed either through YoYo implementing a network_socket_wss server type constant (with the extra S standing for Secure), or editing the functionality of the already existing network_socket_ws.
In any case, this all seems like a pretty massive oversight.

The obvious solution seems to be to move the website to a custom unsecured web server. Hosting a site myself isn't something I'm experienced in doing, but I'm somewhat open to it if it ends up being the only solution. Preferably though, I'd like a solution that:
1: Lets me keep the site hosted on Neocities (i.e. not changing anything on the web server side)
2: Allows the page to have a secured connection (I'm told that an unsecure connection makes it vulnerable to DDOS attacks)
3: Lets the HTML5 client program connect to the server program
4: Doesn't require a complete rewrite of the server program (I'd like to keep it made in GMS, as it has some GMS-specific features like writing surfaces to buffers)

For anyone who may want to try their hand at connecting to the server, the IP and Port are 100.18.37.231 and 35423 for the web socket, though I can't guarantee it'll be up.

Also, I've sent this issue into YoYo. I haven't heard back yet, but I'll update the post/thread when/if I do. I'm working in GMS 2.3.1.
 

FrostyCat

Member
You need to connect to wss://100.18.37.231:35423 instead of just 100.18.37.231:35423. It's the same kind of issue as when people try to make HTTPS requests without including the https:// prefix at the front.
 

Padouk

Member
If i'm not mistaken on the Client your can specify the protocol when connecting:
network_connect(some_socket, "wss://127.0.0.1", 20334);

On the server side, depends on your host but you usually want to setup a url rewrite to an app path instead of exposing the port. That's where you secure the domain
 

Mookal

Member
You need to connect to wss://100.18.37.231:35423 instead of just 100.18.37.231:35423. It's the same kind of issue as when people try to make HTTPS requests without including the https:// prefix at the front.
I added the change (adding "wss://") you and Padouk have suggested (thank you both very much!), but I'm still getting an error, albeit a different one.
1616701809134.png
The error is unfortunately very vague...
EDIT: For clarity, I haven't changed anything besides this in either the client or server programs.
 
Last edited:

Mookal

Member
An update: While having the prefix "wss://" before the IP doesn't work regardless of web server status, having the prefix "ws://" does work, just not when the project is built and running on a web server.
 

Padouk

Member
Yup you are good on the client part now!
I had a chance try a connection to your IP before you close it. Error message: HTTPS handshake to 100.18.37.231 (for #19) failed

It basically means your server is not expecting a secure socket connection.
If you really want to use wss, you would now need to configure and use an SSL certificate for you server.

Thats' the rewriting part I was talking about...

Where are you hosting that GMS server?
At home I guess, on a verizon dynamic ip where you open the port in your home router for the world to see? You'll have a hardtime keeping a SSL for it. Don't you want to hide that information for a bit?
 
Top