[SOLVED] Ajax call times out for virtual players in dev. mode

Game development with Board Game Arena Studio
Post Reply
User avatar
Woodruff
Posts: 412
Joined: 08 March 2014, 00:53

[SOLVED] Ajax call times out for virtual players in dev. mode

Post by Woodruff »

Hello everybody!

Have you ever seen much differences for server response between the normal player and bots?
Let's say I (Tchebychev0) launch a 2p game using "express start" which add a bot player, let's say Tchebychev4.
I notice than the server is quicker to answer when Tchebychev0 makes is move quicker than when it's Tchebychev4.

I have 3 possible actions in the main state: "draw", "meld" or "dogma". "draw" or "meld" have few databases operations on .game.php, "dogma" is heavier.
  • When Tchebychev0 takes any one of the three actions, everything proceeds normally.
  • When Tchebychev4 takes a "draw" or "meld" action, it takes circa 5s to complete, since my internet connexion is quite low...
  • When Tchebychev4 takes a "dogma" action, it is stuck at "Sending move to server..." but finally the request times out :| . When I trace the server job using var_dump, I get no response even in .action.php: I think the error stream can't flush because the server does not finish its job.
I think a better connexion would solve the problem anyway (which I can't have :evil: ), but do you have any idea why the server takes so more time when it's the bot who plays?

Any experience with that?

Thanks!

Tchebychev
Last edited by Woodruff on 21 August 2016, 14:09, edited 1 time in total.
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

Re: Ajax call times out for virtual players in dev. mode

Post by pikiou »

This has never happened to me. I'd guess it's an infinite loop.
Do you log debugging content so you can eventuality cross that off?

If not, here is something to log things to the database:

Code: Select all

function log() {
   $args = func_get_args();
   $line = Array();
   foreach ($args as $arg) {
      $line[] = is_string($arg) ? $arg : var_export($arg, true);
   }
   self::DbQuery("INSERT INTO logs (line) VALUE ('".mysql_escape_string(implode("\n\n", $line))."')");
}
And for the DB:

Code: Select all

CREATE TABLE IF NOT EXISTS `logs` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `line` mediumtext NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Then you check the log table and see what you logged in there!
User avatar
Woodruff
Posts: 412
Joined: 08 March 2014, 00:53

Re: Ajax call times out for virtual players in dev. mode

Post by Woodruff »

Wow, thanks Pikiou!

I managed to solve the problem this way. Indeed, the logs clearly indicated that I was in infinite loop, since the table kept growing... (an = was misspelled to a vicious ==: this piece of code was executed at least once except when the player who launched the action is at the beginning of the table). I was wrong about the complexity of the sql requests since it has nothing to do with that.
I did not managed to log anything using var_dump since apparently the server must finish its job before pushing anything to the client, which is not the case...
This method of logging in database is the solution in that case, thanks Pikiou for pointing that out.

I'll certainly have to use that trick again ;)

Tcheby.
Post Reply

Return to “Developers”