I have a third-party application running on Heroku. I am sending a GET request to this application, expecting a 200 OK from it. Here's my code for this:
HttpRequest req = new HttpRequest(); req.setEndpoint('https://myapp.com/myapp'); req.setMethod('GET'); req.setTimeout(2 * 60 * 1000); Http http = new Http(); HttpResponse res = http.send(req); System.debug('The body is: ' + res.getBody());
However, I get "Read timed out" error if there's is no setTimeout in the code and "Unexpected end of file from server" error if there's setTimeout in the code.
The very code works fine if I change the url to some other app, say Google. I am unable to understand where the problem is. My app works perfectly fine from the browser or from POSTMAN. Not sure why salesforce platform is unable to connect. Any help would be highly appreciated!