I’m developing a multiplayer game with a WebGL client that connects to a Linux server with Unity Game Hosting platform (Multiplay).
My WebGL Client is hosted through HTTPS so, I get this error:
The page at ‘https://…’ was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ‘ws://3X.XX.XX.XXX:9000/’. This request has been blocked; this endpoint must be available over WSS.
It is as if the client, by default, is using ws and not wss to connect to the server.
I believe that the server side (Unity Multiplay) is correctly configurated. In the log I don’t get any clue of the connection type (ws or wss).
By the way, I don’t get any error when I try from localhost (http not https) with xampp.
So, is there any special configuration when building the WebGL client? (or maybe in its hosting? I’m using BanaHosting (shared), which works fine with Gzip or Brotli without fallback with some warnings)? Or when building the server executable?
Or in the code when starting client or server?
I am using this method for both client and server, passing the IpAddress and Port:
Server:
ServerConfig serverConfig = MultiplayService.Instance.ServerConfig;
NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(serverConfig.IpAddress, serverConfig.Port, "0.0.0.0");
NetworkManager.Singleton.StartServer();
Client:
NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(_ipAddressField.text, ushort.Parse(_portField.text));
NetworkManager.Singleton.StartClient();
And this is my Unity Transport configuration. For both it is the same (server and client):
And by the way, this is the log of my test allocation:
StartServer
ServerConfig:
ServerId: 690X290X
AllocationId: 6a6f592X-cbc6-4fXd-8c24-fX15cb4cdXb8
IpAddress: 3X.9X.1XX.1XX
Port: X000
QueryPort: X010
LogDirectory: /mnt/unity/logs/
StartServerQueryHandlerAsync
SQP server: SQP server started on 0.0.0.0:X010
[Netcode] StartServer
[Netcode] Initialize
I hope you can help me and that it can be useful for others who have the same problem. Thanks in advance!