m1ome / iso8583

PHP ISO8583 pack/unpack library
MIT License
14 stars 17 forks source link

Maximum execution time of 30 seconds exceeded #5

Open devsalman opened 7 years ago

devsalman commented 7 years ago

Hi, @m1ome whenever i call $message->pack() in my code i always getting this error:

Fatal error</b>:  Maximum execution time of 30 seconds exceeded in <b>D:\Repository\iso8583-tester\vendor\miome\iso8583\src\Message.php</b> on line <b>73</b><br />

below is my code when i try to pack my ISO8583 message:

$app->post('/send', function($request, $response, $args) {
    $params = $request->getParams();
    $iso = new Protocol();
    $message = new Message($iso, ['lengthPrefix' => 0]);
    $message->setMTI($params['mti']);

    foreach($params['fields'] as $field => $value) {
        $message->setField($field, $value);
    }

    $message->pack();

    $data = ['success' => true, 'message' => 'Request Success'];
    return $response->withJson($data, 200);
});

Any idea?

devsalman commented 7 years ago

i'm trying to figuring out the cause of the problem and it seem (from the error message above) this code is the cause of the problem (but still i don't know why):

https://github.com/m1ome/iso8583/blob/master/src/Message.php#L71-L75

if ($i % 64 == 0) {
      for($i=0; $i<64; $i+=4){
            $bitmap .= sprintf('%01x', base_convert(substr($tmpBitmap, $i, 4), 2, 10));
      }
}

every time my code reach that block it always freeze and then the error Maximum execution time of 30 seconds exceeded is shown.

rkgitvinay commented 6 years ago

@devsalman have you got the solution ? because i getting the same issue.

boy1212 commented 5 years ago

have you got the solution ? because i getting the same issue.