502 Error in establishing connection

Having an issue where I get a 502, Error in establishing connection message about 50% of the time when trying to reach an API endpoint. I never have an issue reaching the endpoint using Postman, only using the Request Method

The call is a little slow to respond, so not sure if there is some timeout I am hitting or what.

Below is the error I am getting and the function that calls the Request Method.

findBarcodeData() {
      console.log('Searching', this.barcodeSearch)
      this.barcodeSearch = this.barcodeSearch.trim()
      var headers = {"Accept": "application/json", "Authorization": "Bearer <%= iparam.apiToken %>"};
      var options = { headers: headers };
      var url = "https://xxxxxx.xxxxxxxxx.com/api/barcodes/find/" + this.barcodeSearch
      client.request.get(url, options)
      .then(
      function(data) {
          if (appLocation == 'new_ticket_requester_info') {
            populateSupplyFieldsNew('barcode', data)
          };
          if (appLocation == 'ticket_requester_info') {
            populateSupplyFieldsExisting('barcode', data);
          };
      },
      function(error) {
          console.log(error)
      })
    },

Anyone have any ideas?

I did find the information in the documentation about the 6 second limitation. That could be the issue here, but is this the expected error?

You get the timeout error if 6 seconds limit is exceeded.

Recently we faced this exact issue in of our app after updating to latest fdk, and it turned out that our node and npm version were not compatible. After fixing it, it got resolved. Maybe this can be the problem in your case too.

1 Like

Hey Bryan the Request Feature of Marketplace platform has a built in timeout of 6 seconds. To overcome this my suggestion would be to use common JS modules like fetch / XHR.

2 Likes

Thanks all. Appreciate the feedback.