0

I have a Google Cloud Function with a Google Cloud Storage trigger that make a request to a endpoint in my server, but this endpoint can take a little time to response and I not sure what should happened with the CF, i.e CF have a limit life and probably my endpoint take more that this time limit, I wanna a solution or a way to have CF that trigger a request to a endpoint and don't wait for the response. Is this possible in CF?

  • Have you considered publish a message to Google Pub/Sub and having your back-end server watch for published messages? Your application can either explicitly use Pub/Sub polling or can use REST and use Pub/Sub push to be notified when a new message is available. – Kolban Oct 24 '19 at 17:24

1 Answers1

0

It depends on what the remote end point does.

When you make a request to a remote API, your Cloud Function opens a socket and starts waiting for the response.

If you don't need the response, you can simply not listen for that response. But that does mean (if programmed correctly) that Cloud Functions will close the socket shortly after sending the request. If your endpoint is not dependent on having an open socket/request that may be exactly what you want.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • so, can I configure the cloud function to close the socket just after made the request? – Abel Penton Oct 24 '19 at 17:24
  • There's no configuration. If you tell the Cloud Functions environment that you're done (return a value, or a promise that resolves quickly), Cloud Functions will stop billing you, and may close open connections at any time. – Frank van Puffelen Oct 24 '19 at 18:00
  • what should happened to the server after the socket is down, this could cancel the request? (btw my server is in Flask) – Abel Penton Oct 24 '19 at 18:42
  • That depends on your server, which wasn't what you originally asked about. I know a decent amount about Cloud Functions, but little to none about Flask. This search result seems relevant though: https://stackoverflow.com/questions/28311299/flask-what-happens-when-a-user-closes-the-browser-while-a-long-process-is-being, as are probably more from this: https://www.google.com/search?q=What+happens+to+a+flask+page+when+I+close+the+request – Frank van Puffelen Oct 24 '19 at 21:43