Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Critical -Unity 2017.3 - WWW with WWWForm not working - Wrong network request (header/body) created

Discussion in 'Windows' started by fcloss, Jan 6, 2018.

  1. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Hi,

    This issue happened for the first time on 2017.3, works on previous version.

    When I call the simple code below or for any other url the yield takes long time and returns always HTTP/1.1 500 Internal Server Error. I can assure that there is no server error, works on any other Unity version and works on any POST tool. The network flow from Fiddler shows some weird content from Unity WWW with form:

    Code (CSharp):
    1. WWWForm wwwForm = new WWWForm();
    2.             wwwForm.AddField("data", enc);          
    3.  
    4.             using (www = new WWW(url, wwwForm))
    5.             {
    6.              
    7.                 yield return www;
    8.             }            
    I have used Fiddler to check what is being sent and as shown below it has invalid data on the body and no Content-Length (I have ommited part of the url):

    POST http://tacticalpad.com/... HTTP/1.1
    Host: tacticalpad.com
    User-Agent: UnityPlayer/2017.3.0f3 (UnityWebRequest/1.0, libcurl/7.51.0-DEV)
    Accept: */*
    Accept-Encoding: identity
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: application/x-www-form-urlencoded
    X-Unity-Version: 2017.3.0f3

    cf
    data=nc1y1puzQHPBriIuFxCIiGnzS5L%2b6Cu1l4yBbpLQCHRjcEGbzSvTqD3dhTnyhbIa4Y6BaMerD3Dacm8zAYGyVPCpCA2nCM66RKkoNsEGeeXY30lWat7bmrYyLhsubLD9DjhShYBt%2beX5H109q5meqNFDgLhuPaQK6oAigdxdMDtXng%2bI%2fvTJg%2bwQprWYhlud
    0

    This request is invalid and causes the server Internal Error, on previous versions everything works as expected and the network request is created successfully.

    It is to me a critical issue as i have several dependencies with network that are not running.

    Thanks in advance,

    Fernando
     
  2. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    @Tautvydas-Zilys any chance you could look at it? I haven't filed the case yet. If you want me to, just let me know.
     
  3. Pavo93

    Pavo93

    Joined:
    Feb 15, 2017
    Posts:
    4
    same here, i have an undefined index error trying contacting my sql table. did you solve it?
     
  4. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    No, I believe the only way right now would be to avoid WWWForm but I have too much code with it already =(
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,738
    This is a known bug, fix is upcoming.
    For now the workaround is to use UnityWebRequest instead of WWW and set chunkedTransfer property to false.
     
    sumpfkraut likes this.
  6. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Any estimate for the patch? We have too much code and plugins using WWWForm, so waiting for the patch is the only solution for us.

    Thanks!
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,738
    It's an issue with WWW class, not WWWForm, the later can be used with UnityWebRequest too.
    It will take at least a couple of weeks to release a fix, can't really promise though, it depends on QA etc.
     
  8. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Ok. We will check if we can update all the codes to WebRequest. @Pavo93, here is the current possible solution.
     
  9. big_3

    big_3

    Joined:
    Apr 20, 2016
    Posts:
    88
    We have the same problem! 2017.3 is a mess.... completely unusable
     
    jgroulx likes this.
  10. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
    works, thanks!
     
  11. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Do you know if it is Windows only or all platforms? I have some plugins for iOs and Mac using WWW and wouldn't like to update all of them because that get updated all the time and I would have to modify again.
     
  12. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,738
    It's cross-platform issue. Chunked transfer was accidentally enabled in WWW class and now we started to see how many servers don't support that yet.
     
  13. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Yes, unfortunately there are many yet. Mine is on Azure and by default disabled, to enable it we need a complete new release, what is not so nice on Azure.

    If you guys add the parameter to enable chunked transfer as on WebRequest, with a default false value, WWW will be perfect =).

    Thanks
     
  14. feenix566

    feenix566

    Joined:
    Jan 30, 2018
    Posts:
    2
    I'm having a similar issue. I'm submitting a request initialized with WWW and WWWForm to a server I'm hosting locally with Django. The server isn't receiving any of my POST variables. It was working fine before I upgraded to 2017.3. I think the version I was using before was 2017.1.
     
  15. Ashiash

    Ashiash

    Joined:
    Nov 24, 2014
    Posts:
    8
    Hi,
    Just stumbled across this thread after posting a very similar question in the HelpRoom forum.
    I've now changed my code in the appropriate places from using the WWW class to use the UnityWebRequest class. However it still doesn't work. Why: Because in Unity 2017.3.0, I can't change the UnityWebRequest.chunkedTransfer property! Meaning I can't set it to false.
    Going back to Unity 2017.2.1 I can set the chunkedTransfer property to false without any problems and the UnityWebRequest then works like a charm.

    Can you please escalate these bugs to be fixed asap? This bug is critical, as in this current state Unity 2017.3.0 is completely useless to me.
     
  16. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Hi, I am setting chunkedTransfer to false on the UnityWebRequest object on Unity 2017.3.0f3. It works as expected:

    Code (CSharp):
    1. UnityWebRequest www = UnityWebRequest.Post(url,wwwForm);
    2. www.chunkedTransfer = false;
     
  17. Ashiash

    Ashiash

    Joined:
    Nov 24, 2014
    Posts:
    8
    Really? That's strange. It hasn't been working for me all day. I can set the properties UnityWebRequest.url, UnityWebRequest.timeout and UnityWebRequest.method etc.etc.

    But with UnityWebRequest.chunkedTransfer and UnityWebRequest.useHttpContinue to true the value in the my debugger (Visual Studio 2017) remains false.

    Here's a code snippet from my source code:
    Code (CSharp):
    1. UnityWebRequest uwr = new UnityWebRequest();
    2. uwr.url = m_strURL;
    3. UploadHandler uploader = new UploadHandlerRaw(aRequest);
    4. uploader.contentType = "custom/content-type";
    5. uwr.uploadHandler = uploader;
    6. uwr.downloadHandler = new DownloadHandlerBuffer();
    7. uwr.method = UnityWebRequest.kHttpVerbPOST;
    8. uwr.useHttpContinue = false;
    9. uwr.timeout = 120;
    10.  
    11. uwr.chunkedTransfer = false;
    12. bool isChunked = uwr.chunkedTransfer;
    13.  
    14. if (isChunked)
    15.     uwr.chunkedTransfer = !isChunked;
    16. .....
    17.  
    Guess what happens: Even after explicitly setting it to false I pass into the if statement. In the debugger the value is still depicted as being true and the code behaves that way as well.
    In Unity 2017.2.1 however everything behaves as expected.
     
  18. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    I haven't used the debugger, I just replaced WWW to UnityWebRequest, set chunked to false and ran, and the POST worked. Then i haven't needed to debug.
     
  19. Ashiash

    Ashiash

    Joined:
    Nov 24, 2014
    Posts:
    8
    Sadly it didn't work for me. So I've had to revert to Unity 2017.2.1.
    This version seems to work fine for me. But I did want to take advantage of the latest Windows Mixed Reality features and native VR support.
    (Currently I'm porting one of our older apps from Unity 5.6.0 to the latest Unity 2017 version. That's why I'm refactoring all the code that used the WWW class to using the UnityWebRequest class.)
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,698
    If you still see the issue, can we get a bug report on it?
     
  21. Ashiash

    Ashiash

    Joined:
    Nov 24, 2014
    Posts:
    8
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,698
    Here is how you can report a bug: https://unity3d.com/unity/qa/bug-reporting

    Do you only need your issue on UWP? If yes, it will probably be the same issue. Otherwise, it's a separate issue and we need a separate bug report for it.
     
  23. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    It shall be fixed on Release notes for 2017.3.1: (I haven't tested yet)
    • Web: Ensured only use non-chunked data transfer in WWW. (974046)
     
  24. pepeSanz

    pepeSanz

    Joined:
    Aug 8, 2013
    Posts:
    3
    www works fine (as before) in Android builds. It fails in the editor (windows) and in UWP builds.

    As it is said here, changing the properties of the UnityWebRequest seem to work, at least in the editor, tomorrow will confirm in UWP build. Thanks a lot, i was getting crazy, better change code than nothing.

    UnityWebRequest w = UnityWebRequest.Post(srvUrl + srvPagTest, form);
    w.chunkedTransfer = false;
    w.timeout = Mathf.FloorToInt(timeout);
    w.useHttpContinue = false;
     
  25. pepeSanz

    pepeSanz

    Joined:
    Aug 8, 2013
    Posts:
    3
    2017.3.1 fixes www in editor but not in UWP build !!!:(!!!
     
  26. pepeSanz

    pepeSanz

    Joined:
    Aug 8, 2013
    Posts:
    3
    2017.3.1 www works in UWP build for ARM !!! but not for X64 !!!!!. I haven't tried X86
     
  27. kerede

    kerede

    Joined:
    Apr 3, 2013
    Posts:
    9
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,698
    We're well aware of the issue of WWW and web request being broken on 2017.3 on UWP with .NET scripting backend (IL2CPP isn't affected). We're working on a fix and we'll have it ready in a patch release soon.
     
    kerede likes this.
  29. emorling

    emorling

    Joined:
    Jul 6, 2015
    Posts:
    24
    subscribe
     
  30. jghospital

    jghospital

    Joined:
    Nov 22, 2017
    Posts:
    17
    Problem is still affecting, right? When is the path going to be released?
     
  31. emorling

    emorling

    Joined:
    Jul 6, 2015
    Posts:
    24
    It is not working In the Editor, but in some places like the Web Browser or on IOS it does work. However, its very irritating to have to export to test code that should work in Editor