Skip to content

UnityWebRequest error www.downloadHandler.text #9

Open

Description

@CodePitch

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);
}
}
}

Activity

  1. sableangle commented on Nov 22, 2024

    @sableangle
    Owner

    could you please share the error message or console?

  2. CodePitch commented on Nov 22, 2024

    @CodePitch
    Author

    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!

  3. sableangle commented on Nov 25, 2024

    @sableangle
    Owner
    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions