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. Dismiss Notice

Curl error 65: neccessary data rewind wasn't possible

Discussion in 'Scripting' started by Pandask, Jul 27, 2021.

  1. Pandask

    Pandask

    Joined:
    Oct 23, 2016
    Posts:
    2
    We are having quite a lot of trouble with Editor and PC build sending POST WebRequests on our server. At random times it throws this error CURL error 65. I tried searching a lot but no solution to be found for us.

    EDIT : The CURL issue happens only on PC build and Unity editor. (Webgl , android unafected)
    We also tried removing the Uploadhandler which prevented crashing but this is not a solutions since we cant upload any data on server this way.
     

    Attached Files:

    Last edited: Jul 28, 2021
    andyz and siddharth3322 like this.
  2. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    144
    I am getting same. It doesn't even stack trace. I wish there was some way to get more info. Just jumping on the thread for notifications.
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    ina likes this.
  4. Pandask

    Pandask

    Joined:
    Oct 23, 2016
    Posts:
    2
    We are using default settings for apache.
    Amazon Linux 2
    Apache/2.4.46 - Aug 24 2020 18:54:20

    This is the best info I can provide for now since our server guy is not present atm.
    If there is any more info you need please ask.
    Project in unity is running 2020.3.13f version
     
    Last edited: Aug 6, 2021
  5. Steamc0re

    Steamc0re

    Joined:
    Nov 24, 2014
    Posts:
    144
    I am fairly sure this is related to using Photon Chat. I don't know their specifics!
     
  6. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,132
    I am getting same error sometimes - 2019 LTS, simple web requests, only gets errors in the editor
    The error is really unhelpful...
     
  7. OneManArmy3D

    OneManArmy3D

    Joined:
    Jun 2, 2011
    Posts:
    189
    unity 2020.3.17f1

    Curl error 65: necessary data rewind wasn't possible
     
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Do you have a project using which we could reproduce it?
    So far this bug hasn't been reported, it would help a lot to have a repro case.
     
    Bunny83 likes this.
  9. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,132
    What is the root of the error in Unity though? - it gives no indication of its cause
     
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Based on error message the server setup is such that Unity sends the data and later has to resend the same data again, but there is a missing implementation piece for that, so the request is aborted.
     
    siddharth3322 likes this.
  11. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,132
    OK but it is no good for Unity to post such error messages. You could post "WebRequest error: Resend failed", or "server error: Curl 65...". As it is, it is not a human readable error. I only know it may be to do with server communication due to this thread!
     
    Last edited: Apr 29, 2022
  12. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,042
    I was facing this issue as well, in Unity 2021.1.13f1 using the POST method of web service call.
    One thing, I have noticed was when I was calling the same web service again after a few seconds, I was getting this error message within the Unity Editor.

    Here you have exact screenshots:
    curl error 1.png

    curl error 2.png

    Here is the actual code that is executing:
    Code (CSharp):
    1.     public void FetchLevelGameQuestions()
    2.     {
    3.         StartCoroutine(FetchLevelGameQuestionsEnumerator());
    4.     }
    5.  
    6.     IEnumerator FetchLevelGameQuestionsEnumerator()
    7.     {
    8.  
    9.         WWWForm form = new WWWForm();
    10.         //form.headers[HEADER_AUTHORIZATION] = AdhocStorage.userProfile.accessToken;
    11.         form.AddField(PARAM_LEVEL_ID, GameManager.Instance.SelectedLevelId);
    12.         form.AddField(PARAM_GAME_ID, GameManager.Instance.SelectedGameId);
    13.  
    14.  
    15.         using (UnityWebRequest webRequest = UnityWebRequest.Post(GameConstants.HOOPSENGLISH_BASE_URL + GameConstants.WEB_LIST_QUESTIONS_URI, form))
    16.         {
    17.             webRequest.SetRequestHeader(HEADER_AUTHORIZATION, AdhocStorage.userProfile.accessToken);
    18.  
    19.             // Request and wait for the desired page.
    20.             yield return webRequest.SendWebRequest();
    21.  
    22.             switch (webRequest.result)
    23.             {
    24.                 case UnityWebRequest.Result.ConnectionError:
    25.                 case UnityWebRequest.Result.DataProcessingError:
    26.                     Debug.LogError("Error: " + webRequest.error);
    27.                     break;
    28.                 case UnityWebRequest.Result.ProtocolError:
    29.                     Debug.LogError("HTTP Error: " + webRequest.error);
    30.                     break;
    31.                 case UnityWebRequest.Result.Success:
    32.                     Debug.Log("\nReceived: " + webRequest.downloadHandler.text);
    33.                     //ParsingUserProfile(webRequest.downloadHandler.text);
    34.                     ParseGameQuestions(webRequest.downloadHandler.text);
    35.                     break;
    36.             }
    37.         }
    38.     }
    39.  
    Please help me to sort out this because my game can't able execute the same web service again.
    If you need anything from my side then let me know.
     
  13. AusAdam

    AusAdam

    Joined:
    Jan 2, 2021
    Posts:
    47
    I have also just started getting this error and not sure why in the editor.
    Curl error 65: necessary data rewind wasn't possible
     
    siddharth3322 likes this.
  14. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    343
    Got this moments ago with 2021.2.12f1.
    Curl error 65: necessary data rewind wasn't possible

    happened once on editor game start, and then webrequests worked again
     
  15. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,132
    If you can recreate consistently - make a bug for Unity.
    They seem unaware of the cause of this (it is an error from some (third-party?) http api which should not be thrown) and want examples of how to get - it is to do with web connections to an apache server maybe. You also get errors for aborting web requests in 2019 (stopped in later versions thankfully), so seems bad practice to me in how http errors are managed.
     
  16. AusAdam

    AusAdam

    Joined:
    Jan 2, 2021
    Posts:
    47
    I am not sure if the devs are still following this or not but it seems to be a problem with their code somewhere. If I use a program like fiddler anywhere and connect through that then I have NEVER got the curl error message. However if I use my normal internet here in Thailand then I get the message sometimes, It seems to happen after you send a webrequest it returns and then you send another one in 3-4 seconds, If you wait longer then this then it does not seem to happen.

    Basically a quick fix for anyone with this problem is to do this

    Code (CSharp):
    1. if (www.result == UnityWebRequest.Result.Success)
    2. {
    3.     //it worked and no curl error
    4. }
    5. else
    6. {
    7.     if (instance.retries < 1)
    8.     {
    9.         instance.retries++;
    10.         // redo web request
    11.     }
    12.     else
    13.     {
    14.         //it failed twice, only happens during a server error with the script.
    15.     }
    16. }
     
  17. Pinhel

    Pinhel

    Joined:
    Jan 12, 2015
    Posts:
    1
    Try to check if the JSON is valid.

    Code (CSharp):
    1. private IEnumerator GetJSONData()
    2. {
    3.     string data;
    4.  
    5.     using UnityWebRequest unityWebRequest = UnityWebRequest.Get("URL");
    6.     yield return unityWebRequest.SendWebRequest();
    7.  
    8.     if (unityWebRequest.result == UnityWebRequest.Result.Success)
    9.         data = unityWebRequest.downloadHandler.text;
    10.     else
    11.         data = unityWebRequest.error;
    12.  
    13.     if ((data.TrimStart().StartsWith("{") && data.TrimEnd().EndsWith("}")) ||
    14.      (data.TrimStart().StartsWith("[") && data.TrimEnd().EndsWith("]")))
    15.     {
    16.         Debug.Log("it's a JSON");
    17.     }
    18.     else
    19.     {
    20.         Debug.Log("it's not a JSON");
    21.     }
    22. }
     
    ooooDeveloper likes this.
  18. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    I know this thread is a little old, but I just received similar messages today after integrating Playfab just a couple days ago.

    Curl error 56: Receiving data failed with unitytls error code 1048578
    Failed to send session data. Error: /Event/WriteEvents: Unknown Error
    Curl error 65: necessary data rewind wasn't possible
    Failed to send session data. Error: /Event/WriteEvents: Unknown Error

    Uploaded a bug report: https://fogbugz.unity3d.com/default.asp?1424036_6br6rorjf8ft439q
     
    siddharth3322 likes this.
  19. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,132
    If the free libcurl (https://curl.se/libcurl/) is the basis for all UnityWebRequest it should probably be mentioned in the docs. But as said - errors from that library should not produce errors directly like this - they should be fed up to the result from UnityWebRequest to be dealt with by the developer.
     
  20. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,042
    Still I was facing similar error multiple times when I call custom web services related to project.
     
  21. NithishP

    NithishP

    Joined:
    May 3, 2019
    Posts:
    4
    Same issue happening to me.
     

    Attached Files:

    MetalMonkey666 likes this.
  22. sivaprakashpb

    sivaprakashpb

    Joined:
    Mar 19, 2018
    Posts:
    1
    Did you fix this error?how ?
     
  23. cratica

    cratica

    Joined:
    Dec 11, 2016
    Posts:
    55
    Having the same problem. In my game, players can search for other players in the game from the game server (wordpress database). If you do too many searches fairly quickly then it throws Curl Errors 65 and 52
     
  24. AusAdam

    AusAdam

    Joined:
    Jan 2, 2021
    Posts:
    47
    there is no fix to this (been having this problem for 3 years now) just check if UnityWebRequest.Result.Success is true and if not then run a function that will run the web request again. I have a web game that uses a server backend and this has worked everytime, It seems only the first webrequest will fail sometimes but the 2nd one always goes through.

    Obviously add in some code so that it will only resend the webrequest once if it fails and not loop continuously.
     
    ina and crossyfootball like this.