UnityHTTPServer icon indicating copy to clipboard operation
UnityHTTPServer copied to clipboard

UnityWebRequest error www.downloadHandler.text

Open CodePitch opened this issue 1 year ago • 3 comments

IEnumerator EnviarPregunta(long code, string p) { using (var www = new UnityWebRequest("http://127.0.0.1:5880/Recibido?code=" + code + "&msg=" + p, "GET")) { yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log(www.downloadHandler.text); } } }

CodePitch avatar Nov 21 '24 22:11 CodePitch

could you please share the error message or console?

sableangle avatar Nov 22 '24 09:11 sableangle

I am trying to communicate from the Edge web browser to the unity editor where the httpserver is. If you type in the browser url directly:

funciona

it works correctly and returns a Json.

But if I make this request from a compilation in webGL it returns null (or I don't know how to get the json)

error

www.downloadhandler.text <--- is null

public ReturnResult Recibido(long code, string msg) { ReturnResult result = new ReturnResult { code = code, msg = msg }; return result; }

Thanks!

CodePitch avatar Nov 22 '24 10:11 CodePitch

public ReturnResult Recibido(long code, string msg)
{
    ReturnResult result = new ReturnResult
    {
      code = code,
      msg = msg
    };
    return result; // try set the breakpoint in Unity editor here!
}

To tested the issue is from webgl side or the UnityHTTPServer side, I suggest to set a breakpoint as upper, and see if the break point is trigger or not.

If the breakpoint is triggered, then I think the issue is inside the WebGL build, maybe something like il2cpp script code strip etc.

sableangle avatar Nov 25 '24 04:11 sableangle