Check internet connection from WebGL build

Dealing with code from plugin that crashes the WebGL program when not connected to the internet. At the current stage of development we have to use a local html file to run the game.

Below are the methods we have tried (and failed):

Ping: Not supported in WebGL.

UnityWebRequest: Cannot access web resources that aren’t on the same server as the WebGL project (Which we aren’t even hosting since we are using local files).

Try Catch: Plugin code does not get caught.

Application.logMessageReceived += LogCallback: Crashes before it calls / Doesn’t call at all.

Maybe try Application.internetReachability

It’s maybe late for this but I hope this can help someone.

Application.internetReachability is not reliable for checking if you’re actually connected.
I suggest making a simple HTTP request, if everything goes right then you’re connected.

public IEnumerator CheckInternetConnection()
        const string _echoServer = "";

        UnityWebRequest _request = UnityWebRequest.Head(_echoServer);
        _request.timeout = 5;

        yield return _request.SendWebRequest();
        ConnectionManager.Connected = !_request.isNetworkError && !_request.isHttpError && _request.responseCode == 200;