Search Unity

SendWebRequest curl timeout error

Discussion in 'Editor & General Support' started by Robdon, Mar 27, 2020.

  1. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    I use SendWebRequest() to send some stats data to my server while doing Alpha/Beta testing.

    Sometimes the host/connection is unresponsive, so to make sure it doesn't effect the game, I use the timeout parameter set to 10 seconds.

    The problem I have, is that 'if' the send times out, it crashes the editor. If I try it in the runtime, then I get a red error message that pops up (the normal error type when in dev build).

    Error:
    Curl error 28: Operation timed out after 2000 milliseconds with 0 bytes received
    (Filename: C:\buildslave\unity\build\Modules/UnityWebRequest/Implementations/TransportCurl.cpp Line: 760)

    I'm guessing the crashing editor it some kind of bug Unity side, but how can I stop the runtime popping up error messages?

    It seems stupid that there is an 'error' message for something I've specifically asked it to do.

    I've tried putting it in a try/catch, and that didn't work.

    Code:
    Code (CSharp):
    1. using (UnityWebRequest send = UnityWebRequest.Put(Consts.ALPHA_URL + Consts.ALPHA_SEND, "SOMEDATA")) {
    2. send.timeout = 10;
    3. yield return send.SendWebRequest();
    4. }
     
    Thoma1207 and MilenaRocha like this.
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Do you have "Stop on Error" enabled in editor console?
    This bug should be fixed in latest versions, so either upgrade or turn that off.

    And, just in case, 10 second timeout is too low for production code.
     
  3. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    Hi, yes I did have "stop on error", I'm on 2018.4.18f1, which until a few days ago was the 'latest'.

    Unchecking the stop on error, stopped the editor crashing.

    But, the main issue was the error message popping up on the players screen. How can I stop that?

    It's not stopping the game, but it tends to make our game look rather unprofessional with red errors popping up, when we are supposed to be in Beta and nearing release, so I need to suppress it.

    Thanks, Rob.
     
    pKallv, Thoma1207 and MilenaRocha like this.
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    It should only appear in Development builds.
     
  5. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Aurimas why can't we catch that error? Could you make it non blocking like other Unity errors?
    When debugging it's very annoying to have to unpause every time. I need to leave the "pause on error" as that is useful to find real errors in my code, but a connection timeout is not an error that should require attention if it is handled in the code. And the error is handled properly in my case, but Unity keep pausing the editor before my error handling code has a chance to run....
     
  6. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    862
    Just ran into this too. Pretty annoying.
     
  7. CaseyLee

    CaseyLee

    Joined:
    Jan 17, 2013
    Posts:
    41
    Just got done debugging this error... it is far from an expected outcome from adding a "timeout" counter to a web request. throw a warning not an error would make more sense.

    unity 2022.2.13