Jump to content

Bad Gateway 502 - Retries but already took


 Share

Recommended Posts

We're having an issue using the Sage SDK PHP library in which at times we get a Bad Gateway response. This seemed to trigger a retry and ended up doubling up the transaction as it actually went through on the sage side eventhough we got the Bad Gateway on the response. 

Are there anyways that we can prevent this double up? 

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
Link to comment
Share on other sites

  • 4 weeks later...

The question I have (as i've verified sometimes we just get this 502) is that since it doesn't return a success or fail -> we had assumed fail -> the system retried and doubled up the invoices as the sage side did process it.

Is there anyway to make sure if it gets retried that it doesn't double up a data send?

Link to comment
Share on other sites

  • Members

@Ming Han Chung

What you can do is set the unique ID field to true and pass a unique value in the controlid attribute. Once successfully consumed it will return an error if you attempt to use it again.
 

<?xml version="1.0" encoding="iso-8859-1"?>
<request>
 <control>
  <senderid>*******</senderid>
  <password>*****</password>
  <controlid>ControlIdHere</controlid>
  <uniqueid>true</uniqueid>
  <dtdversion>3.0</dtdversion>
  <includewhitespace>true</includewhitespace>
 </control>
 <operation transaction='false'>
  <authentication>
   <login>
    <userid>****</userid>
    <companyid>*****</companyid>
    <password>**********</password>
   </login>
  </authentication>

<content>
 <function controlid="12345675">
  <readByQuery>
    <object>APBILL</object>
    <fields>*</fields>
    <query></query>
    <returnFormat>xml</returnFormat>
    <pagesize>100</pagesize>
  </readByQuery>
 </function>
</content>
 </operation>
</request>

Link to comment
Share on other sites

 Share

×
×
  • Create New...