Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting internal error on Amazon Marketplace API Requests

I've downloaded Amazon's Marketplace SDK and I'm trying out one of the samples in the samples dir. However, I'm getting an exception with the following details whenever I try it:

Caught Exception: Internal Error
Response Status Code: 0
Error Code: 
Error Type: 
Request ID: 
XML: RequestId: , ResponseContext: , Timestamp: 
ResponseHeaderMetadata: 

I have got CURL enabled with SSL as well. What am I doing wrong?

like image 628
Ali Avatar asked Jan 13 '13 13:01

Ali


3 Answers

This answer is for future reference. For in-depth troubleshooting, see comments on the question.

The empty response indicates a failed connection to the Amazon server. In this case, HTTP worked fine, but HTTPS did not. As turning off CURLOPT_SSL_VERIFYPEER in the cURL settings solved the issue, it appears that the Amazon server was not using a valid SSL certificate.

Having CURLOPT_SSL_VERIFYPEER turned on checks if the requested host has a valid certificate and lets cURL return false if it doesn't. When CURLOPT_SSL_VERIFYPEER is off, invalid certificates (e.g., self-signed) are accepted and return the regular response.

like image 195
tvkanters Avatar answered Nov 15 '22 18:11

tvkanters


For future reference. In the new version of the SDK the options are referenced in the client.php as follows

private function getDefaultCurlOptions() {
    return array (
      CURLOPT_POST => true,
      CURLOPT_USERAGENT => $this->config['UserAgent'],
      CURLOPT_VERBOSE => true,
      CURLOPT_HEADERFUNCTION => array ($this, 'headerCallback'),
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_SSL_VERIFYPEER => true,
      CURLOPT_SSL_VERIFYHOST => 2
    );
  }

setting

CURLOPT_SSL_VERIFYPEER => false,

did the trick in my case. As I am not a security expert, however, no recommendation from this point of view. At least its working and you are probably not loosing 1 whole day as I did.

like image 24
Alexander De Beur Avatar answered Nov 15 '22 17:11

Alexander De Beur


I experienced a very similar connection issue with Amazon. It was the sample files bundled with the Amazon php api, which contain a following configuration array:

$config = array (
  'ServiceURL' => $serviceUrl,
  'ProxyHost' => null,
  'ProxyPort' => -1,
  'MaxErrorRetry' => 3,
);

and if this is copied over and not modified

'ProxyPort' => -1,

will result in an attempt to connect through a proxy port -1 which will of course fail (issue tracked by checking curl error). I hope this helps.

like image 35
dadasign Avatar answered Nov 15 '22 19:11

dadasign