Async HTTP crash on Android

JeanSwamp

Member
Hello,

I am getting the real-time (non local device based time) from an URL using http_get("http://worldtimeapi.org/api/timezone/Europe/Madrid");

Then I am using the Async HTTP event to do everything I need with my time and format. Everything works perfect on Windows.

However I just compiled into my Android device and the game crashes with an error as soon as the Async HTTP event is called...

Any ideas?

Thanks
 
D

Deleted User

Guest
i am not sure if this works, but you can also try:

GML:
try{http_get("http://worldtimeapi.org/api/timezone/Europe/Madrid");}catch{}
it should block unhandled crashes.

EDIT:
ok that wont work on gml (works on c#) :D
and on gml, syntax is this to hack fix crashes: (no "catch" needed)
GML:
try{http_get("http://worldtimeapi.org/api/timezone/Europe/Madrid");}
 
Last edited by a moderator:

Nidoking

Member
If all you want is something that doesn't crash, you can turn your computer off entirely, unplug it, pack it in its original box, and stuff it in an attic. The correct solution to a problem is to fix the problem, not ignore it.
 
D

Deleted User

Guest
If all you want is something that doesn't crash, you can turn your computer off entirely, unplug it, pack it in its original box, and stuff it in an attic. The correct solution to a problem is to fix the problem, not ignore it.
Very ignorant response.

Try-catch is for unhandled crashes.

What i suggested is to handle the crash by implementing try-catch.

You can try for example set a variable to something with try-catch, and check if it was not set properly then set it to something else to handle...

If you cant implement code snippets, then maybe you should go to the attic? šŸ˜
 

chamaeleon

Member
I believe try/catch is irrelevant here and any crash issue pertains to the code in the Async - HTTP event code, due to insufficient validation of the data in async_load. Having said that, if one is going to recommend a try block, a proper catch should be included.
GML:
var url = "http://worldtimeapi.org/api/timezone/Europe/Madrid";
try {
    req = http_get(url);
} catch (e) {
    show_debug_message("Failed to request " + url + ": " + e.message);
}
Code:
11-15 21:27:51.966 32751  6001 I yoyo    : HttpGet("http://worldtimeapi.org/api/timezone/Europe/Madrid", 0)
...
11-15 21:27:51.987 32751  6035 I yoyo    : Exception = java.io.IOException: Cleartext HTTP traffic to worldtimeapi.org not permitted
11-15 21:27:51.987 32751  6035 I yoyo    : HttpResultString( "IOException", 404, 0 )
...
11-15 21:27:52.016 32751  6001 I yoyo    : { "response_headers": 0.0, "http_status": 404.0, "url": "http:\/\/worldtimeapi.org\/api\/timezone\/Europe\/Madrid", "id": 0.0, "status": 0.0, "result": "IOException" }
Last line is a single show_debug_message(json_encode(async_load)) in Async - HTTP. The catch block is not run, and the async event does get invoked (but not with the content one might expect).

If the Async -HTTP event assume that there is valid data simply because it was invoked that would be likely source of a crash, in my opinion.
 
Top