phpcodeigniter

CodeIgnitor $_POST empty on requests with different parameters


I am trying to debug a problem with an application in CI. I have experience in PHP but not with CI. This app was written by someone else. It has been running untouched for the past 4 years. In the past 10 days it started returning errors. I traced it down to a controller. It starts by checking the parameters. These include values plus an attached file and are sent using multipart/form-data.

$post_details = $_POST;
$json_request = json_encode($post_details);
write_to_log($json_request);
if ($post_details && isset($post_details['acc']) && !empty($post_details['acc']) ... ){
   ...
} else {
  die(json_encode("code"=>500,"error"=>"Missing parms");
}

Note: Above is simplified paraphrase of actual code which is bit lengthy.

Anyway, the write_to_log shows all the parameters that were sent to it. Normally, another program on another server calls this function. For my testing, I used Postman.

Now the problem: When I call the function from Postman in rapid succession, the log shows the parameters. If I change one value and call again after waiting 30 or so seconds, log shows parameters.

But if I call within a few seconds, log shows that no data was received in $post_details. Also, I don't get the response in Postman but get a timeout after a while. All subsequent hits then show the parameters.

As I said, this program has been running untouched for years and this started happening only a couple of weeks back.


Solution

  • If this has been happening for a few weeks, it would be better to look at the server configuration rather than the code.

    If the code was the problem, it would have been there from the time it was created.

    Since the problem occurs at different request intervals, it is possible that the firewall is handling too many requests (usually a DDoS protection policy).

    First, try restarting HTTP server like nginx or apache. Then, monitor the packets received by the server.