1

I have code running on a node server. I ported it to GCF. When I run the port, all things seem to work until I make request to URL. It times out.

If I comment out the request() call, the code exits as expected. I've searched and searched, but I cannot find a solution to the issue. Any help would be appreciated?

Is there some configuration setting in GCF that I am missing that is preventing me from calling out to a service outside of GCP?

options = {
  url: `${id_url}&title=${title}&artist=${artist}&album=${album}`
};
request(options, function (error, tresp) {
  if (error || tresp.statusCode !== 200) {
    console.error('Error from TuneIn:', tresp.statusCode);
  }
});

Any ideas?

Jamey Kirby
  • 143
  • 2
  • 6
  • That's a lot of code ... can you simplify the logic for illustration purposes to just a fragment that fails by removing other functions and leaving just the minimum to see the issue? How long does the internal REST outbound call normally take? – Kolban Oct 26 '19 at 16:58
  • 1
    Sorry for the long code. Here is where it fails. Normally the REST call takes a few ms. It sends three values in the URL and returns. – Jamey Kirby Oct 26 '19 at 17:03
  • I've had this happen in the past and needed to up the [memory limit](https://console.cloud.google.com/functions/list) and timeout for that function. Granted it was the firebase functions but I believe it's a similar process. – Phix Oct 26 '19 at 17:09
  • I'd always assumed that a REST request using this API was asynchronous. Are you sending a response to the original GCF function as a result of the request result? – Kolban Oct 26 '19 at 17:16
  • No. I am calling out to a completely different service; not Google. – Jamey Kirby Oct 27 '19 at 01:53
  • kolban, you were correct. resp.send('OK'); fixed the issue. Thanks for pointing me in the right direction. – Jamey Kirby Oct 27 '19 at 16:04

1 Answers1

1

This finally fixed my problem. The function was timing out even thought my REST was actually working.

resp.send('OK');
Jamey Kirby
  • 143
  • 2
  • 6