Huge delays in webhooks

Hi all,

we’ve tested a particle photon based system on Friday with little delays for the webhooks - and today it takes up to a minute to deliver these webhooks. As we created some kind of go-live arcade style button, it’s a no go for that demo.

Any idea?

2 Likes

@hansamann, it is really difficult to help without any view into your webhook or code! Can you share more details?

There’s not much to share :slight_smile: I cannot share the webhook.json, it’s a PUT agaisnt a cloud server - it works perfectly from a node.js script on our laptops. We have a WebUI running that switches a page immediately based on that webhook.

The code on the photon is simple - a button-pressed code:

const int BUTTON_PIN = D0;
const int LED_PIN = D1;
bool wasPressed = false;

void setup() {
pinMode(BUTTON_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
}

void loop() {

bool pressed = digitalRead(BUTTON_PIN);
if (pressed && !wasPressed)
{
    Spark.publish("launchevent");
    digitalWrite(LED_PIN, HIGH);
    delay(250);
    digitalWrite(LED_PIN, LOW);
    delay(250);
    digitalWrite(LED_PIN, HIGH);
    delay(250);
    digitalWrite(LED_PIN, LOW);
    delay(250);        
}

wasPressed = pressed;
delay(250);

}

I’ve changed the event name - this is for a launch event in a few minutes, literally, and it worked perfectly last Friday.

The question would be: is there a badly performing server system right now? The status page does not mention anything, but am not sure how ‘live’ that page is.

Any ideas?

@peekday123 - if I can send you the details via DM/private message, I can for sure share that webhook info. But it’s a simple put request - similar to this here:

{
“event”: “launch”,
“url” : “http://someserver.com/timestamp”,
“requestType”: “PUT”,
“mydevices”: true
}

  • ok, the event is incorrect in the button pressed code above - I had the event name changed. The events match, that is not the issue. Also, in the dashboard, I see the events come in immediately. But then the webhook must be delivered super way later…

@hansamann, you are calling a bunch of delays after the Spark.publish(). I would not rely on these to call the background task and instead would replace those delays with non-blocking millis() delays where you call Spark.process() during the delay:

unsigned long wait = millis();
while (millis() - wait < 250) {
  delay(10);   //optional
  Spark.process();
}

This will allow the backgroud firmware to process the received event more quickly IMO. :smiley:

Hi @peekay123, thx - that’s definitely even better, totally agree. But we got these events to hit our server in a few moments on Friday and now it takes forever. Well, I really suspect a overloaded server or so… but anyway, we have some node.js script to fake the webhooks, but it would be nicer if it were real! Thx for the optimization, will add that after the event.

Do you have access to the backend engineers at @Particle to quickly ask them if there is such an issue?

Heya, @Dave Here,

I have an update for webhooks that I can roll out that might improve the speed of delivering these hooks, but there is also an important change in how responses are sent from hooks. Previously some results were “double-serialized”, and now they should be just singly serialized, so extra quotes / slashes may disappear. I think this shouldn’t impact most users negatively, but it might be a potential gotcha. I can try rolling out this update and see if it helps?

edit: I’ll also quickly check on that box to see how it’s doing.

Thanks,
David

Try it now, that box was mad, kicked it for you. I’ll look into the cause of that delay.

Thanks,
David

1 Like

Hey, thx. I’ve not experienced the issues again so far. Thx a lot!

1 Like