cancel
Showing results for 
Search instead for 
Did you mean: 
Post a Question

web api rest is not always working ...

hi i use the rest web api using php 

mostly when i am using the add access rule , the action does not succeed 

i just need to refresh the page few times , sometimes 5 times the action complete successfully

can someone help with the reason for that ?

Labels (2)
0 Kudos
7 Replies

Re: web api rest is not always working ...

the code i use 

$curl = curl_init();
$url = $this->checkPointMgmntServer.$Name;
showMsg('running function: ',$Name,'');
showMsg('running json: ',$json,'');
#echo $this->cpSid;
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_USERPWD, "abc:password");
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 0); // set POST method
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
# curl_setopt($ch, CURLOPT_SSL_VERIFYSTATUS , FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'x-chkp-sid: '.$this->cpSid

));

curl_setopt($ch, CURLOPT_POSTFIELDS, $json); // add POST fields
//curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json;"));
try {
$result = curl_exec($ch);
}
catch(Exception $e)
{
print_r($e);
}
$trimed = json_decode($result, true);


return $result ;

}

0 Kudos
Admin
Admin

Re: web api rest is not always working ...

On what hardware (CPU type, number of cores, RAM) is the R80.x Management running on?

Also, what exact version of code?

Also, what API call exactly are you making with this code?

0 Kudos

Re: web api rest is not always working ...

the machine is a vm  and all functions working but the add access rule 

that succeed only once in 5 to 10 refresh of same code 

0 Kudos

Re: web api rest is not always working ...

just to clarify 

i use same function to do a lot of action like adding time object adding host etc 

on all of them it runs on first time smoothly 

only when i am runnig the add access rule it fails and after some trials it is at the end succeed 

that means the json i am passing to function is ok....

but still somthing causing it to fail 

0 Kudos
Admin
Admin

Re: web api rest is not always working ...

This could easily be the result of an underpowered management server, which is why I asked the questions I did.

Please review my questions again and provide answers.

In the case of a VM, please tell me what ram/CPU has been allocated to it,

You also set the timeout really low (10 seconds)—you might try a higher timeout.

0 Kudos

Re: web api rest  is not always working ...

vm with 24 gig memory 12 cpu cores i changed the 10 seconds to 120 sec 

no special results 

thanks for your response

0 Kudos

Re: web api rest is not always working ...

Make sure you run latest jumbo fix on your management, at least higher than 142 as there have been multiple fixes for API. Also for larger rule and objects bases switch API java to 64 bit and increase default memory heap