Is there a way to tell Webhooks to wait a while when going to a site to retrieve data?
I ask because I am retrieving JSON from a site that can be slow, and having the Webhook wait a couple of seconds for a response should solve a problem that I am having with ‘null’ responses when I know that there is data available, which shows up during the next request. I think that the website is just too slow responding sometimes.
@Awake, that is a very interesting idea which may explain why some webhooks are failing to return data. @Dave, is it possible to add a “time to respond” parameter in a webhook that sets a maximum time a webhook will wait for a response?
Ooh, interesting. It should wait for the response to finish, but I’ll definitely look into that.
Thanks!
David
@Dave @peekay123
This is what I am seeing that causes me to suspect a timing issue with webhooks:
Every 30 seconds I fire off a request to a webhook.
I only get data back once in a while (data updates every few minutes so it essentially static during this test.)
I added a 5 second delay after the webhook call to slow down things on my end, with no effect.
Steps are:
- Print “getting feed”
- Call Webhook ( Spark.publish(“get_feed”); )
- Print “in feed” and data.
Interestingly, the function called by the webhook definition only runs once in a while:
Particle.subscribe(“hook-response/get_feed”, gotFeedData, MY_DEVICES);
The gotFeedData function is what prints “in feed” and data. So the function isn’t even being called if the webhook call doesn’t work.
@Dave @peekay123
Additional info:
The roundtrip average time for my request is 5.7 seconds using a simple GET loop.
BTW. I gave up on using Webhooks for my project because it was just too unreliable. Using Httpclient and a fairly straight forward string field matching instead.
Hi @Awake,
I’m glad your project is unblocked, I’ll keep working on this on my end! Thanks for all your help / feedback!
Thanks,
David
I am seeing similar behavior. Sometimes my pub is posted 4-6 times before I get a response. Cosmetically, it drives me crazy and functionally I’m exceeding the burst rate which only makes things worse and perpetuates the problem. I’m going to try and set a timer of 20 seconds before firing the event again but when I test directly from the weather underground API its generally a .21ms response time. It’s usually right when I’ve restarted my core that it is at its worst. Would that somehow affect this?
Something else that would great is if we could put an outbound rate-limit per day/month or whatever and when it is exceeded the Particle cloud wouldn’t attempt to call the hook but reply with a rate-limit exceeded statement. This is especially helpful on early projects where the details are being ironed out.
Hi @LukeUSMC,
Good idea! At the moment there are a handful of rate limits that should publish an event back to you talking about the rate limit being exceeded. But I like the idea of a way for people to set some rules about that.
Thanks!
David