Possible webhook issue?

So, I’ve noticed for the last few months a weird behaviour were some of our devices seem to misidentify ourselves when sending data. We may not have the most straightforward way to do things, but the way things work, a device sends several packets of data with a certain ID that are re-aggregated in the cloud (GCP). In the reply to some of these packets a device ID is sent back to the device, with additional configuration sometimes (our devices are asleep and offline most of the time). What I’ve noticed lately is, when two devices are connected at the same time, it sometimes - rarely, but often enough to be annoying - seems like the wrong device might receive the reply that was destined to the other device. I can’t swear it’s what is happening, and I also suspect a fail in the cloud function that handles the packets and replies to them.

My question is: since Particle is acting as a relay between a device and cloud servers via the integrations, could it be technically possible a device would receive the event reply that was destined to another device? Again, not saying it happens. It would just make me feel better if the answer was it is not technically possible :slight_smile: Then I’d focus 100% of my investigation of finding the flaw in the cloud function…


PS: subscription to event replies is made on event names using the device ID:

          System.deviceID() + "/hook-response/" + RTU_EVENT + "/0",
          responseHandler, MY_DEVICES);

(reply packets are short, so we only focus on first packet, hence the “/0”. This was added very recently, from “/” before, but shouldn’t have an impact IMHO)

Technically any device could get a webhook response, but in your scenario it should never happen.

Webhook responses can be subscribed to by any device claimed to the account that generated the webhook request. However, this is an uncommon use case. Normally you want the requester to get their own response back, and no others.

Since you’ve configured your webhook with the Device ID as the prefix to the hook response, that should be sufficient to make sure you don’t get responses for other devices.

1 Like

Thanks Rick. That’s what I thought too. So no way, some queuing system would mismatch things on Particle side, to be clear? :upside_down_face:

It seems pretty unlikely. Each webhook request and response is handled separately as an asynchronous chain of completion functions. It’s actually pretty likely that two requests that come in around the same time will land on different physical servers because they’re load distributed.

1 Like