WebGl on WSS connection: Failed to construct 'WebSocket'

I’m developing a multiplayer game with a WebGL client that connects to a linux headless server.

Using the UseWebsockets does the magic and alla works smooth until I load the game from an http connection.

To make it work over WSS I proxied the game using ngnix. Testing the connection using WebSocket Echo Server | WebSocket.org all works as expected on the server side. I proxied (e.g) the WS from the 7777 port to a secure 7778 port (with working SSL certificate)
but… if a load the webgl on a https connection Unity give me this error as soon as I try to connect to the 7778 secure port.

“Uncaught SecurityError: Failed to construct ‘WebSocket’: An insecure WebSocket connection may not be initiated from a page loaded over HTTPS”

What I’m expected to do on the webgl client side? How to configure it to use WSS instead of WS?

1 Like

This post is quite old but I have the same problem with Unity Game Hosting (Multiplay).
I believe Unity Server side is configured correctly, so is there some kind of special configuration when make the WebGL Build (or maybe in its hosting? It’s hosted in BanaHosting, in which can run with Gzip or Brotli without fallback with some warnings)? Or when make the Linux server build? Or when connect to the server (WebGL) or make the server (Linux)

I use NetworkManager.Singleton.GetComponent().SetConnectionData() for both Linux Server and WebGL Client, passing IdAddress and Port only.

And this is my Unity Transport configuration. For both is the same (server and client)
9688898--1382105--unity-transport.png

I hope someone can help us. Thank you!