SendWebRequest curl timeout error

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:

using (UnityWebRequest send = UnityWebRequest.Put(Consts.ALPHA_URL + Consts.ALPHA_SEND, "SOMEDATA")) {
send.timeout = 10;
yield return send.SendWebRequest();
}
2 Likes

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.

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.

3 Likes

It should only appear in Development builds.

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…

Just ran into this too. Pretty annoying.

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