Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal Restful - Could not resolve host

i have a problem with the "Paypal PHP Restful SDK". My yproblem is, that (in sandbox mode) i get sometimes the error "Could not resolve host ...". This happens about every 10'th payment session in sandbox-mode.

Here the logged error:

mod_fcgid: stderr: PHP Fatal error:  Uncaught exception 'PayPal\\Exception\\PayPalConnectionException' with message 'Could not resolve host: api.sandbox.paypal.com' in /var/www/xxxxx.com/httpdocs/app/paypal/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:137

the corrospending line from the SDK is:

//Throw Exception if Retries and Certificates doenst work
if (curl_errno($ch)) {
    $ex = new PayPalConnectionException(
        $this->httpConfig->getUrl(),
        curl_error($ch),
        curl_errno($ch)
    );
    curl_close($ch);
    throw $ex;
}

Info: I have no Certificate on my vServer

Does somebody know, what is working wrong?

like image 645
AppGeer Avatar asked Apr 11 '16 10:04

AppGeer


1 Answers

There's insufficient information to fully diagnose the problem and find the the culprit. You can have i.e. networking problem on your run environment, DNS setup problem, connection timeouts etc etc. Yet as the issue occurs frequent enough to reproduce it you may try to resolve api.sandbox.paypal.com using other tools like host or dig, or you can even craft PHP script that would simply do:

error_reporting(E_ALL);
var_dump(gethostbyname('api.sandbox.paypal.com'));

and run it many times to see if the problem would occur here too. If it does, then I am afraid SO is not the right place to continue chasing this type of issues but as workaround/temporary fix you could either use IP (currently 173.0.82.78) address instead of api.sandbox.paypal.com or edit your local /etc/hosts file and add

173.0.82.78  api.sandbox.paypal.com
like image 63
Marcin Orlowski Avatar answered Oct 04 '22 08:10

Marcin Orlowski