UnrealEngineHTML5 / Documentation

542 stars 183 forks source link

HTML5 Socket Connection Failure #92

Open robbythedude opened 3 years ago

robbythedude commented 3 years ago

Preface

Due to this being an HTML5 multiplayer game, I turned on the "Experimental WebSocket Networking Plugin". I successfully compiled, packaged, and hosted the ThirdPerson example project on my Azure server. I can load the game in multiple browsers just fine.

Due to all of the trouble shooting I've been trying, I have disabled IIS on my Azure server and use the compiled HTML5LaunchHelper.exe that is generated during Packaging. I wanted to make sure both Local and Remote Azure were running the same Web Server experience.

Problem

The game will not connect to my remote dedicated game server using the terminal's open command when I load the game from external Azure site (https://testwinvm.eastus.cloudapp.azure.com/VirtualShow.html). Example of this Scenario's architecture below:

Image of Scenario 1

When I load the game from local (http://localhost:8000), the game connects perfectly fine to my remote dedicated game server. Example of this Scenario's architecture below:

Image of Scenario 2

I've been inspecting the Debug Console between both scenarios. I thought this might be an CORS issue, but I do not notice any difference in the Headers being sent between the two scenarios. I thought maybe the MIME type encodings are incorrect between the two scenarios, but they look exactly the same. Example below, left is local/scenario two and right is remote/scenario one:

Image of Headers and MIME Types

The only thing I notice in the Debug Console that is different between the two scenarios is after the game is already fully loaded in browser. When I execute the terminal's open command, the console logs varying outputs.

Scenario One Output

Image of Remote Console Output

Scenario Two Output

Image of Local Console Output

I believe I found the Error Codes for Socket Connections. Below is a snippet of the Error List. Error Code 26 is "Connection already in progress". Error Code 23 is "Host is Unreachable". Why would the Host be unreachable in scenario one while it can be easily reached in scenario two and loading the standalone win64 client?

var ERRNO_MESSAGES = {
 0: "Success",
 1: "Arg list too long",
 2: "Permission denied",
 3: "Address already in use",
 4: "Address not available",
 5: "Address family not supported by protocol family",
 6: "No more processes",
 7: "Socket already connected",
 8: "Bad file number",
 9: "Trying to read unreadable message",
 10: "Mount device busy",
 11: "Operation canceled",
 12: "No children",
 13: "Connection aborted",
 14: "Connection refused",
 15: "Connection reset by peer",
 16: "File locking deadlock error",
 17: "Destination address required",
 18: "Math arg out of domain of func",
 19: "Quota exceeded",
 20: "File exists",
 21: "Bad address",
 22: "File too large",
 23: "Host is unreachable",
 24: "Identifier removed",
 25: "Illegal byte sequence",
 26: "Connection already in progress",
 27: "Interrupted system call",
 28: "Invalid argument",
 29: "I/O error",
 30: "Socket is already connected",
.
.
.
 156: "Level 2 not synchronized"
};

Additional Notes

The project is hosted here: https://testwinvm.eastus.cloudapp.azure.com/VirtualShow.html

Project download to run locally is here: https://testwinvm.eastus.cloudapp.azure.com/VirtualShow.zip

The dedicated game server IP for terminal's open command: 20.55.123.171

TL;DR It's like Firefox is blocking my Socket Connection when it's opening the site on a remote server... But it's totally cool with Socket Connections if the site is being opened on localhost. I do not know why. Can you help?

The-Crocop commented 2 years ago

so we are struggling with a similar issue. The browser only allows websocket connections without ssl from trusted domains like localhost or 127.0.0.1 thats why its working locally. When your client is running under a real hostname the browser doesnt allow you to create an insecure websocket connection. Therefore you would have to use wss://hostname:443. However the problem there is that the open command only allows ip addresses. I managed to create a secure websocket proxy with the unreal server in the background. Now we are struggling with finding a way to connect to it from the game.