The problem is, their server is frequently returning time out errors on connection, thus leaving me without any quotes.
I thought about automatically making 2 or 3 new requests after, say 5 seconds. If the retries can't be succeeded, then give a "No quote avaliable at this time, try again later" to the customer.
As it is now, the "no quote" msg is returned in the first call. The code is as below:
Code: Select all
$conexao = fsockopen("www.correios.com.br", 80, $errno, $errstr, 30);
if (!$conexao) {
//echo "$errstr ($errno)<br />\n";
echo 'No connection available. Try again later.'; // This is the msg I don't want to show
return false;
} else {
// process quote here
}