How to check a 3rd-party API endpoint if online before trying to connect to it?

Hello,

Happy Easter!

I tried to search the forums but I can’t find any information (yet). So far, from my search, the possible solution is to implement the Wappler Bull Queues extension. But it is somewhat complicated for my part as I need to use REDIS.
I would like to know if someone has a solution already implemented for my inquiry.

What I would like to do is to check first if a 3rd-party API endpoint is online before I send a query via API.
What is currently happening from what I understand is that nodejs connects to the 3rd-pary API endpoint and will timeout (ETIMEDOUT error) after several seconds. I would like to catch this timeout error and reflect in my dashboard that the API servers are offline. If it is not possible to catch this, then is there a way to check whether that API endpoint is offline or online?

Using the Wappler Bull Queues extension will allow me to use a timeout in connecting to the 3rd-party API. Is there any other solution?

Thanks in advance.

Basically you want an API Action step with timeout, you started to overcomplicate when you added Bull MQ to the discussion :laughing:

No one does this exact solution, use the timeout option for the API Action instead. You can make use of Try/Catch step to mark somewhere (e.g. in your database) the API Action is offline (Catch)

Hi @Apple, thanks for the response. I saw that topic last time but it was not confirmed to be valid.
Were you able to make it work?

Hi zitrowave,

I haven’t personally tested if it works, I guess you’ll need to test it :slight_smile:

Ken (the creator of that topic) is a well-known Wappler expert, therefore unless proven otherwise I believe his solution is valid (despite the lack of confirmation).

You’re welcome!

Hi @Apple, I used the Try/Catch step and not set the time-out. I guess this is okay for my use for now.

Thank you!