• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Reasons http "status" returns -1??

Pfap

Member
I'm dealing with a pretty frustrating issue because I've debugged thoroughly and I'm still stuck.

First off the show_debug_message(async_load[? "http_status"]);
Is returning 200.


I'm setting some global variable from a server and then using what that server returns to post and get from a database. When I set the variable from inside gamemaker it makes the request and everything work fine.

From gamemaker I post to the key: "piece" the value: "1" and then have a different gamemaker client request the key "piece" expecting a "1" back, but the async_load status returns -1. When I get the "piece" key from the server's command line it returns the expected "1" and in all my tests the server is responding fine.

Gamemaker also works fine if I hardcode the global.key variable. But when I get it from the server
show_debug_message(global.key); outputs "piece" which is what I expect, but then the status remains -1.

When I'm playing around with all this stuff I create a windows executable get that running and then go back to the ide and press play. Would that have something to do with it??



In the create event I make a request to my server
Code:
 var state, str;
state = ds_map_create();
//I may add a unique id to the username stored below
my_variable = "1" + which_key;
show_debug_message(my_variable);
   {
  
 
   ds_map_add(state, "key", my_variable);//i'm pretty sure im not using this order doesnt matter

   }
str = json_encode(state);

key_get = http_post_string("http://url", + str );
//key_get = http_post_string("http://url", + str );

ds_map_destroy(state);

In the async event I set global.key with the result
Code:
if ds_map_find_value(async_load, "id") == key_get{
show_debug_message("key get");
show_debug_message(async_load[? "status"]);
 show_debug_message(async_load[? "http_status"]);

var status = ds_map_find_value(async_load, "status");
if status == 0
{
path = ds_map_find_value(async_load, "result");
}
else{
 
 alarm[0] = 60;
 exit;
}
              
show_debug_message(path);
 


global.key = path; //if the user happens to get their own key just send them back to the main menu??


show_debug_message(global.key);

}
In the above the global.key debug message outputs "piece", but the below request doesn't work unless I manual provide the key.

Code:
[/COLOR][/FONT][/LEFT]
[FONT=arial][COLOR=rgb(222, 222, 222)]
[LEFT]
 var state, str;
state = ds_map_create();
//I may add a unique id to the username stored below

show_debug_message(my_variable);
   {
  
 
   ds_map_add(state, "key", global.key);

   }
str = json_encode(state);

key_get = http_post_string("http://url", + str );
//key_get = http_post_string("http://url", + str );

ds_map_destroy(state);







I'm trying to make a multiplayer connect four or tic tac toe game where a string gets passed back and forth with game data. Like 9 pieces for tic tac toe, but if I have to switch it for every match it's going to get tiring. I was maybe going to try just having an array with a bunch of keys available. But I think my current way should work and all the debugging I've done shows it should also.

But am I missing some main reason for a -1 status?
 
Last edited:

Pfap

Member
Ok it's some problem with encoding and php. I have a mess to untangle now, but it sounds like it should be as simple as using utf-8 decode on my server, or doing something on Gamemaker's side.... not sure so I won't mark this as solved yet.
 

Zixtix

Member
I have also been struggling with that the response from a php site would return 200 but -1 status in the async_load for some of our players in China. The weird thing is that when I use Fiddler to sniff the http traffic and decode HTTPS, this behavior would go away. My guess is that some background process is messing with the server's response and cause the GMS client to not be able to parse the response, but I have not confirmed this theory yet.
 
Top