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?
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
You can always try flushing your DNS cache, restarting the network interface.
You can also try pinging and check if PayPal API is indeed pingable(reachable), try changing to Google DNS too, maybe that'll sort the issue.
Related
My dilemma is that I have two domains running on localhost, domain_a and domain_b. They're both running nginx, apache, and php-fpm. domain_a is running CodeIgniter 3.0.0, and domain_b is running CodeIgniter 4. In another VM, I had domain_a in a Docker container, and was able to hit the API endpoints in domain_b without any issues. Development work made it a requirement to have them both be on the same server, as it's close to how it will be in other environments.
For specifics, we're using the PHP oAuth module, and it throws an error that "making the request failed (dunno why)", which is extremely helpful. After some digging, I found that I could hit other endpoints without issue (such as google.com and a known endpoint outside these domains). I attempted to use cURL in place of oAuth (just a simple test to hit the endpoint), and I consistently get the same error.
tls_process_server_certificate:certificate verify failed
The certs I use are all self-signed for both domains, and I'm able to reach both domains from within the browser without issue. If it matters, both domains have user certs when logging in, but the users aren't the same, as each domain has their own self-signed CA.
My current code is this:
$conn = new OAuth($consumer_key, $consumer_secret, $oauth_sig_method);
$conn->enableDebug();
/*
if (is_on_local()) {
$conn->setCAPath('path/to/cert.cert');
}*/
$conn->disableSSLChecks();
$token = $conn->getRequestToken($auth_url);
I left the commented out part in to show what I've tried - I've tried pointing that to the system cert, domain_a CA, and domain_b CA, none of which worked. It looks like (for some reason) $conn->disableSSLChecks() isn't working, but I'm not sure of that. The error thrown is in the call to getRequestToken().
My etc/hosts file:
127.0.0.1 domain_a.tld
127.0.0.1 domain_b.tld
The actual TLD isn't tld, but again, they work in the browser and it worked before when domain_a was in Docker.
I've already tweaked domain_a enough so CI 3 works with PHP 8, so I'm convinced the problem is talking from one domain to the other. I'm running RHEL 8, and I've already got SELinux set to Permissive (actually disabled, I think, for development). There's nothing in httpd, nginx, php-fpm, or firewall logs. The only indicator I have is what I get from CI 3 logs in domain_a:
Severity: Warning --> OAuth::getRequestToken(): SSL operation failed with code 1.
OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /path/to/file
Severity: Warning --> OAuth::getRequestToken(): Failed to enable crypto in /path/to/file
Severity: Warning --> OAuth::getRequestToken(domain_b/oauth/access): Failed to open stream: operation failed in /path/to/file
I feel like the answer is right there, I'm just not seeing it.
As usual, shortly after explaining my issue I found the fix.
Currently, I have the endpoint as https://domain_b.tld/oauth/access. After some tinkering, I got a different error about SSL version. That put me on the track to the correct answer:
http://domain_b.tld:port/oauth/access. I'm able to hit the endpoint now without issue. I've got a virtual hosts file that, even though both domains are on the same port, I had to specify it or the call fails.
If anyone else runs into this issue, check the base URL. I never would have thought about hitting http rather than https as a solution.
Have a docker container build using php-ssh2. php version 7.2 When trying to use
$con = ssh2_connect('hostname');
I am getting Error starting up SSH connection(-43): Failed getting banner . Interesting thing is 43 here. Whats the significance of 43. What does that mean? Also any idea how to fix this? There is no heavy load, running connection manually.
Deepdive into libssh2
This number -43 is an error code that comes directly from libssh2, specifically LIBSSH2_ERROR_SOCKET_RECV. The Failed getting banner message is the dynamic error message that accompanies the error code. These two pieces of information give the location where this error is thrown, namely in the receive_banner.
Underlying problem
It was the result of the socket throwing a receive error when libssh2 tried to read from it as part of initialising your SSH session. Either the server is misconfigured and is not sending a banner or the underlying connection disconnected for some reason.
Solution
The best course of action seems to have adequate retrying in place for these kinds of errors. You are connecting to a network which is an action that can fail. As the number of servers you are connecting to increases, you are going to run into errors that are a result of the underlying network. Adequate error handling is your best course of action.
You can find how to set exception handlers from the PHP docs.
I'm using PHP to make SOAP request. I do have information of the web service from the third party. Basically what they have give me:
The full URI request ( http://xx.xx.xx.xx:xxxxxx/some/services/BasicDo )
Username & Password
I am pretty new however I could understand a bit how PHP SOAP things work. However in the example I found the URL called is something like http://xx.xx.xx.xx/services/myservice?wsdl which is not really same with what I have with me. Additional question here is what should I ask them? Perhaps what is the name of wsdl file?
Also so far I have this code with me:
try{
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
}
catch(SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
But from the console, I received status 500 Internal Server Error. I don't know how this can be, I am expecting something from the catch block. Somebody please clarify me this. Thank you in advance.
Unfortunately, it seems like no matter what you try (e.g. passing array('exceptions' => 0), SoapClient() will throw an uncatchable E_ERROR on network connection issues. This bug is still present as high up as PHP 5.5.4 (REF).
Summary:
Test script:
$client=#new SoapClient('garbage',array('exceptions'=>FALSE));
echo 'OK';
Expected result: We should see "OK",
Actual result:
If we use register_shutdown_function to display the contents of error_get_last(), we get:
Array
(
[type] => 1
[message] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'garbage' : failed
to load external entity "garbage"
)
To explain why you suddenly get this error without changing anything on your system, and to explain why SoapClient works on your local machine and not on your production system, it is most likely a firewall issue.
Here is what another person reported that solved his problem:
I solved my problem. It was actually an issue with my firewall. The
firewall was dropping packets sent via PHP, but via curl or wget were
not being dropped. I added a rule for all traffic from that server and
increased the packet drop length and everything is working great now!
Advice:
My best advice at this time to write some code in the same PHP file that checks if the SOAP service url resolves and loads properly before calling the SoapClient.
Add these codes at head of the file to see where the error happen
ini_set('display_errors','1');
error_reporting(E_ALL);
I am not sure what the issue may be but I did the following to debug this issue when I encountered it
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
Things you can do:
Create a PHP file. Name it anything. Write the following code there:
ini_set('display_errors','On');
$client = new SoapClient("http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl", array('login'=>"myusername",'password'=> "mypwd"));
var_dump($client);
exit;
Run the file.
Chances are this will show you the required exception.
In my case, Our server used a proxy which I had not passed in the parameters due to which I was getting the issue.
Let us know how it goes.
Thanks
First you need to make sure you have access to the SOAP server.
From the machine that is running your php script try to access the wsdl file and check if it is valid.
you can for example use wget http://xx.xx.xx.xx:xxxxx/some/services/BasicDo?wsdl then open the saved file and see what you are getting. Is it a valid wsdl?
Once you have sorted out our access, then you need to read the documentation here and here. You may need to authenticate differently or pass other options.
As for why the catch block is not picking up your exception, you are only catching SoapFault. The 500 internal server error can be caused by anything.
I really appreciate all of the answers given. I am actually working with another party which I don't have any access on the remote side. My job is to make SOAP request to the server. However it turned out that there is NO web service available for me. So I ended up using cURL to send raw POST of SOAP request. :-)
My site hasn't been able to accept payments for a few hours now. I've been getting this error message:
Unexpected error communicating with Stripe.
If this problem persists, let us know at support#stripe.com.
(Network error [errno 77]: The one-time function was previously
called and failed. Its error code is no longer available)
I'm running PHP through Apache and the code hasn't changed. I recently updated my server's packages to pick up SSL updates. Could that be causing a problem?
I was able to fix this by restarting Apache.
If you are using linux. Restart php-fpm and nginx it should work too.
I'm trying to run both my API and my client in the same Vagrant VM. In the client I'd like to use Guzzle. When I try to set up a simple test, I get the following error from curl:
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message '[curl] (#6) See http://curl.haxx.se/libcurl/c/libcurl-errors.html for an explanation of cURL errors [url]
When I use a Github url instead, it all works fine. One thing I'm sure of, is that there is no typo in my url.
I have both client and API pointing to the ip-address of my VM, and both run fine separately.
I also ran into a topic on which it was suggested to use a cacert.pem certificate in php.ini, which I have tried, but it didn't work.
Any that knows how to solve this?
Stupid of me. I had to place 127.0.0.1 api.dev in the hosts file on my VM.
The error number 6 (CURLE_COULDNT_RESOLVE_HOST) means that libcurl failed to resolve a host name to an IP address.