Getting ESOCKETTIMEDOUT on request method

My app was working fine before and I was getting response to my API calls fine but since yesterday I keep getting 502 or 504 errors on local testing and after uploading the app respectively

here is my app.js file

var client;

init();

async function init() {
  client = await app.initialized();
  client.events.on('app.activated', renderText);
}

function jsonEscape(str)  {
  return str.replace(/\n/g, " ").replace(/\\/g," ")
}


async function renderText() {
  const textElement = document.getElementById('apptext');
  const ticketData = await client.data.get('ticket');
  const {
    ticket: { description_text }
  } = ticketData;

  try {
    let response = await client.request.invokeTemplate(
      "ChatGPT", {
        "context": {},
        "body": JSON.stringify({
          "model": "gpt-3.5-turbo",
          "messages": [{"role": "system", "content": "You are a helpful assistant."}, 
          {"role": "user", "content": "Provide Customer Sentiment in the Service Ticket raised below and the best way to make them happy\n" + description_text}
          ]
        })
      })
      //textElement = JSON.stringify(response)
      var rep = JSON.parse(jsonEscape(response.response));
      var rep2 = rep.choices[0].message.content;
      textElement.innerHTML = rep2;


  }
  catch(err){
    textElement.innerHTML = "Error request fail: " + JSON.stringify(err);
  }
}

and here is my requests.json file

{
    "ChatGPT": {
        "schema": {
            "method": "POST",
            "host": "api.openai.com",
            "path": "/v1/chat/completions",
            "headers": {
                "Authorization": "Bearer <my-api-key>",
                "Content-Type": "application/json"
            }
            
        }
    }
}```

The code looks okay. This looks like some network traffic restriction, likely from OpenAI. Can you share the exact error message you see?

If I test the app locally I get this

Error request fail: {“status”:502,“headers”:{},“response”:“Error in establishing connection”,“errorSource”:“APP”,“attempts”:1} (

Or if I upload the app , I get this

Error request fail: {“status”:504,“headers”:{},“response”:“Timeout error while processing the request”,“errorSource”:“APP”,“attempts”:1}

If I test the app locally I get this

Error request fail: {“status”:502,“headers”:{},“response”:“Error in establishing connection”,“errorSource”:“APP”,“attempts”:1} (

Or if I upload the app , I get this

Error request fail: {“status”:504,“headers”:{},“response”:“Timeout error while processing the request”,“errorSource”:“APP”,“attempts”:1}

Hey @Karankalsi

did you find a solution yet? Facing the exact same issue when doing a POST request to an internal service.
IT guys have whitelisted FD IPs and told me that there was no one knocking at our firewall.

Best,
Tom

Hello,

my issue is resolved and it was on the serverside.
Guys who developed the service didn’t tell me (or they were not aware), that the service runs on another port than standard https.
So I just had to add the port to the domain and service is running perfect now.

Hope you got your’s resolved too in the meantime @Karankalsi!

Best
Tom

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.