lineofflight / peddler

Amazon Selling Partner API (SP-API) in Ruby
https://lineofflight.github.io/peddler/
MIT License
307 stars 130 forks source link

RequestThrottled response is not raising as expected #153

Closed IanVaughan closed 3 years ago

IanVaughan commented 4 years ago

The readme says that Peddler::Errors::RequestThrottled will be raised but its not for me.

=> #<Excon::Response:0x00007f8b80860728
 @body=
  "<?xml version=\"1.0\"?>\n<ErrorResponse xmlns=\"http://mws.amazonservices.com/schema/Finances/2015-05-01\">\n  <Error>\n    <Type></Type>\n    <Code>RequestThrottled</Code>\n    <Message>Request is throttled</Message>\n  </Error>\n  <RequestID>88f144921...</RequestID>\n</ErrorResponse>\n",
 @data=
  {:body=>
    "<?xml version=\"1.0\"?>\n<ErrorResponse xmlns=\"http://mws.amazonservices.com/schema/Finances/2015-05-01\">\n  <Error>\n    <Type></Type>\n    <Code>RequestThrottled</Code>\n    <Message>Request is throttled</Message>\n  </Error>\n  <RequestID>88f14492...</RequestID>\n</ErrorResponse>\n",
   :cookies=>[],
   :host=>"mws-eu.amazonservices.com",
   :headers=>
    {"Server"=>"Server",
     "Date"=>"Wed, 23 Sep 2020 15:16:25 GMT",
     "Content-Type"=>"text/xml",
     "Content-Length"=>"299",
     "Connection"=>"keep-alive",
     "x-amz-rid"=>"T21BZA...",
     "x-mws-request-id"=>"88f14492...,
     "x-mws-timestamp"=>"2020-09-23T15:16:25.585Z",
     "x-mws-response-context"=>"v6znF1u9XFsmCSGj...",
     "Vary"=>"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent"},
   :path=>"/Finances/2015-05-01",
   :port=>443,
   :status=>503,
   :status_line=>"HTTP/1.1 503 Service Unavailable\r\n",
   :reason_phrase=>"Service Unavailable",
   :remote_ip=>"54.239.39.192",
   :local_port=>57924,
   :local_address=>"192.168.0.17"},
 @headers=
  {"Server"=>"Server",
   "Date"=>"Wed, 23 Sep 2020 15:16:25 GMT",
   "Content-Type"=>"text/xml",
   "Content-Length"=>"299",
   "Connection"=>"keep-alive",
   "x-amz-rid"=>"T21BZA...",
   "x-mws-request-id"=>"88f14492...,
   "x-mws-timestamp"=>"2020-09-23T15:16:25.585Z",
   "x-mws-response-context"=>"v6znF1u9XFsmCSGjS3GtFPwj...",
   "Vary"=>"Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent"},
 @local_address="192.168.0.17",
 @local_port=57924,
 @remote_ip="54.239.39.192",
 @status=503>

Using list_financial_events_by_next_token

hakanensari commented 4 years ago

It sounds like you are running an older version of Peddler? This was added in versions ~>2.0.

IanVaughan commented 4 years ago

Sorry for not including the versions initially, but we are on a recent version.

peddler (2.4.3)
hakanensari commented 4 years ago

You can configure Excon, the underlying HTTP library, to expect certain HTTP status. Could your code by any chance be adding 503 to the default list?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.