• chen li 5
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
We building integration between Salesforce and PHP.
Build REST service in PHP to fetch data from MySQL database and return data in JSON format. It is working fine for first 2-3 Callouts then Salesforce shows us Gateway timeout Error in debug logs. We tested web-service with ARC,Postman,https://www.hurl.it/ many mores and it's working fine.
Below are the HTTP Request code.
Request
string searchText = 'buzz';
HttpRequest req = new HttpRequest();
req.setEndpoint('http://domainname.com/api/getQueryData.php?cachebuster=' + system.now().millisecond());
req.setMethod('POST');
req.setTimeout(30000);
req.setHeader('Accept', '*/*');
req.setHeader('Cache-Control', 'no-store');
req.setHeader('Content-Type','application/json');
string bodyReqeust = 'SELECT * FROM  tableName where '; 
bodyReqeust = bodyReqeust +' Name LIKE \'%'+searchText+'%\'';
bodyReqeust = bodyReqeust +' OR Description LIKE \'%'+searchText+'%\'';
bodyReqeust = bodyReqeust +' LIMIT 10';

map<string,object> mapRequest = new map<String,object>();
req.setBody(JSON.serialize(mapRequest));

Http http = new Http();
HTTPResponse res = http.send(req);
system.debug('res.getBody()::'+res.getBody());

Response :

System.HttpResponse[Status=Gateway Time-out, StatusCode=504] System.HttpResponse[Status=Gateway Time-out, StatusCode=504]"|0x207ad0fb


ERROR: The requested URL could not be retrieved http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License

body :lang(fa) { direction: rtl; font-size: 100%; font-family: Tahoma, Roya, sans-serif; float: right; } :lang(he) { direction: rtl; } -->
"CacheHost: proxy-ord.net.salesforce.com
ErrPage: ERR_CONNECT_FAIL
Err: (110) Connection timed out
TimeStamp: Mon, 11 Sep 2017 12:13:02 GMT

ClientIP: 
ServerIP: 

HTTP Request:
POST /api/getQueryData.php?cachebuster=841 HTTP/1.1
Accept: */*
Cache-Control: no-store
User-Agent: SFDC-Callout/41.0
SFDC_STACK_DEPTH: 1
Content-Type: application/json
Pragma: no-cache
Host: domainname.com
Proxy-Connection: keep-alive
Content-Length: 138
X-Forwarded-For: 10.223.198.130
">support@salesforce.com</a>"

System.HttpResponse[Status=Gateway Time-out, StatusCode=504]

Can someone help Us?