Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 2017.3 WWW problems

Discussion in 'Scripting' started by eizenhorn, Dec 20, 2017.

  1. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    Hello! Guys, were there any changes in WWW or WWWForm? Because after update to 2017.3 POST requests (www to url with WWWForm) broken (empty form data received on server, or, maybe, incorrect headers).
     
    shaneparsons likes this.
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,644
    Can you show the code sample on how you use WWW?
    I think there were fixes related to how we encode the form and we were fixing chunked transfer support in UnityWebRequest which accidentaly went to WWW too (we're reverting that in latest fixes).
    Have you tried using tools like Fiddler to monitor traffic, see what data is being sent?
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    Hi! Ofcourse i'm using fiddler for check request data :) The form leaves, but I suspect that the problem, as you said, with the encoding, because on the server side (python with a flask) the request is not parsed (and return empty array), on the previous version (2017.2.0f3) everything works and flask can parse form. Code sample is very simple:

    public WWW POST(string url, Dictionary<string, string> post)
    {
    WWWForm form = new WWWForm();
    foreach(KeyValuePair<string, string> post_arg in post)
    {
    form.AddField(post_arg.Key, post_arg.Value);
    }
    WWW www = new WWW(url, form);
    StartCoroutine(WaitForRequest(www, "Synchronization..."));

    return www;
    }

    Tomorrow I will make 2 identical requests from two different versions of the engine, and compare them, then I'll say more in detail :)
     
    Last edited: Dec 20, 2017
  4. nbe_seabery

    nbe_seabery

    Joined:
    May 18, 2017
    Posts:
    2
    Hello,
    I am experiencing a similar issue with WWW and post request.
     
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    You use Google App Engine and Python on server side?
     
  6. nbe_seabery

    nbe_seabery

    Joined:
    May 18, 2017
    Posts:
    2
    I am using Apache server with php (slim as framework)
     
  7. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    I am having the same issue. My python server thinks the form data is empty.
     
  8. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
  9. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    Thanks @tonemcbride, but I don't think it's an escape sequence issue. My form.AddField() keys and values are plain text with no special characters. They just aren't being sent.
     
  10. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    Not certainly in that way. The form leaves correctly, not empty and the data in it is. However, the flask module in GAE does not work correctly. On clean node.js, python, .net and others, the form is parsed normally and correctly. In flask, the parser drops and returns an empty array.
     
  11. Lardalot

    Lardalot

    Joined:
    Jun 19, 2013
    Posts:
    10
    +1 WWWForms are completely broken in 2017.3. Everything was fine in 2017.2, then I updated to latest, and it's broke. The server reports the form post data is empty. EG in php $_POST[] contains nothing at all.

    All my client and server code hasn't changed...only my Unity version, now I'm left with a dead project and have to roll back my unity version. Merry Christmas from Unity :)
     
  12. Lardalot

    Lardalot

    Joined:
    Jun 19, 2013
    Posts:
    10
    I've just rolled back to 2017.2 and my forms are working perfectly again.
    I've submitted a bug report, haven't had a ticket id response yet tho.
     
  13. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    553
    We also got problems with it.
    It seems that Unity 2017.3 WWW uses header of "Transfer-Encoding: chunked" instead of "Content-Length".
     
    Last edited: Dec 26, 2017
    nukespoon likes this.
  14. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    Yes, that's it, they changed it. In view of that, many platforms and libraries (flask, GAE) do not understand the stream.
     
  15. kgronquist

    kgronquist

    Joined:
    Jan 18, 2016
    Posts:
    1
    +1... I am SO glad I found this thread. I thought I was losing my mind. I am a fairly new Unity developer, so I thought it was me. Has anyone tried 2017.3 beta 4 to see if that helps?
     
    Last edited: Dec 28, 2017
  16. CEOManDan

    CEOManDan

    Joined:
    Dec 17, 2016
    Posts:
    2
    Thank god, I thought there was something broken with my database
     
    shaneparsons likes this.
  17. andlline

    andlline

    Joined:
    Nov 7, 2014
    Posts:
    6
    Estou com o mesmo problema. Tive que regressar para versão 2017.2. Agora está funcionando! WWWForm está totalmente quebrado na 2017.3
     
  18. Jovaan

    Jovaan

    Joined:
    Aug 1, 2014
    Posts:
    12
    Same problem here. Should have googled this BEFORE I spent 3 hours looking into my server code - everything related to WWWform stopped working with 2017.3. Dear Unity - when is fix coming?
     
    shaneparsons likes this.
  19. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    I’m answered before - this is not Unity bug, this problem - many old systems don’t understand chunk streaming. Clear node.js works fine with chunks and unity 2017.3 WWWForm.
     
  20. Jovaan

    Jovaan

    Joined:
    Aug 1, 2014
    Posts:
    12
    I found straightforward solution. Use wwwform as before, but as follows:
    UnityWebRequest www = UnityWebRequest.Post(URL, wwwform);
    www.chunkedTransfer = false;
    yield return www.SendWebRequest();

    string returntext = www.downloadHandler.text;
    byte[] returndata = www.downloadHandler.data;

    This enables using code that relies heavily on wwwform, as mine does. I use it to access mysql via php server. The money line is www.chunkedTransfer = false which makes request fall back to older compatible header.
     
  21. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    Unfortunately the WWW class does not have a chunkedTransfer member like UnityWebRequest does.

    So, we need to either stuck using 2017.2 or need to rewrite our libraries based on the WWW class to not use it.
     
  22. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    553
    A fast solution for the client side, would be to:
    Look at the source of the WWW code in 2017.3,
    Duplicate it to your project with another class name,
    Set in the relevant code parts www.chunkedTransfer = false;
    And then replace in all the relevant places on your code, to use your own class instead of WWW.

    In 2017.3, the WWW class is just a wrapper for UnityWebRequest.
     
  23. alxcancado

    alxcancado

    Joined:
    Aug 17, 2013
    Posts:
    13
    Thank's guys! I have this same problem, I can't go back to the 2017.2 right now, so I looked for every POST in my code, set request.chunkedTransfer = false and everything works again.

    I was pulling my hair before :D
     
    shaneparsons likes this.
  24. MikePanoff

    MikePanoff

    Joined:
    Apr 29, 2015
    Posts:
    20
    Our solution was to replace all of our WWW classes with UnityWebRequest.

    That didn't take too long as the APIs are very similar.

    This way we could set chunkedTransfer = false because UnityWebRequest exposes it.

    Unity, if you could please expose chunkedTransfer to the WWW class as well, it would fix most people here by them adding just one line of app code.
     
    nukespoon likes this.
  25. andlline

    andlline

    Joined:
    Nov 7, 2014
    Posts:
    6
    I'm not updating for 2017.3 because of this. I hope they solve it.
     
  26. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,654
    Enough to use the ancient and crooked server parts, the progress does not go so that everyone stumbles on the spot, we updated our server part and everything works fine, because normally understands chunkedTransfer
     
  27. tonyram19

    tonyram19

    Joined:
    Jun 29, 2013
    Posts:
    8
    I'm having the same issue on 2017.2, 2017.3, and 2018.1 beta. Setting chunkedTransfer = false does not solve the issue for me. Any help would be greatly appreciated.
     
  28. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,644
    Try setting useHttpContinue to false too.
     
  29. dataflox

    dataflox

    Joined:
    Jun 1, 2015
    Posts:
    2
    Fix issue: if your server use SSL then use https:// in your form

    Iam Using Unity 2017.3.1f1

    Code (CSharp):
    1. WWWForm form = new WWWForm();
    2.         form.AddField("name", "huhu");
    3.  
    4.         using (var w = UnityWebRequest.Post("https://myserver.com/wwwform.php", form))
    5.         {
    6.             yield return w.SendWebRequest();
    7.             if (w.isNetworkError || w.isHttpError) {
    8.                 print(w.error);
    9.             }
    10.             else {
    11.                 print("Complete");
    12.                 print(w.downloadHandler.text);
    13.             }
    14.         }
     
    Last edited: Mar 28, 2018