Webhooks (love them) questions

Dave and team, we appreciate the web hooks a ton. A couple of issues:

  1. Hooks were all setup and running fine, then with the rollout of the new dashboard today, they stopped working. I simply deleted them and re-created them and then they were back up and running. Any idea why we would need to delete and re-create them? Also only one of the hooks shows on the dashboard even though both are getting called.

  2. When my server gets a web hook request, I reply with a Content-type: application/json header and two letters, for example “LB” not including the quotes. However, the data received by our core and shown in the dash board is ““LB”” Why are quotes being put around my response? Should I be replying in a different way? Instead of raw text, should I reply in JSON e.g. { “data”: “my response”, “coreid”: “coreid_that_im_replying_to” } (UPDATE: replying in JSON doesn’t help at all)

  3. How can I respond to an individual core? When my core subscribes I have to use MY_DEVICES in order to get any result:

Spark.subscribe(“hook-response/LOGDATA”, getLogResponse, MY_DEVICES);

If I attempt to use:

Spark.subscribe(“hook-response/LOGDATA”, getLogResponse, Spark.deviceID());

it doesn’t find any response. Is this because my hook response doesn’t include the coreid with it? If so, how can I include it? I want to have a single hook be able to service multiple cores but only an individual core at any time should see any response.

1 Like

One answer to my one of my own questions that might be helpful for others. A web hook response will only show in the dashboard if your web server replies with at least 1 byte of data. If you server doesn’t reply with any content (outside of a header) the hook response will not show in the dashboard.

1 Like

@jeiden and @jtzemp,

maybe something for you guys?

Thanks for the bump Kenneth. Haven’t heard anything back yet. We now have 3 cores in-house for testing a new product/service and we definitely need to figure out how to get a core to only subscribe to it’s own web hooks and not that of the others (worst case scenario is that the server returns the coreid and then the data but is seems a big waste of bandwidth to have to send that to every core and then parse it out.)

While the quotes aren’t a critical thing either, sure would be nice to know why they’re there and if we should plan on an update to remove anything other than the exact content returned by the server.

@phippster,

you can simply use a unique event name and set the myDevices flag to true and it should work well :smile:

I’m not too sure about the quotes issues but if i hear anything i will post back here :wink:

@kennethlimcp That wouldn’t be a solution as you are limited to 20 web hooks total which means you would be limited to 20 unique events and therefore 20 devices and the firmware for each device would be different (unless you’re using the coreid for the event name). We are planning on deploying hundreds if not thousands of these so we need them to respond to their individual subscriptions but share a few events and webhooks.

All of our devices will be logging data, but we only need each one to respond to the log data that it sent up.

Just a stab in the dark here - which got me into trouble before, but I refuse to learn :wink:

Could you retry this either by using

  Spark.subscribe("hook-response/LOGDATA", getLogResponse, Spark.deviceID().c_str()); 

or copy that string into a char devID[25] and pass this in?

Hi, Phippster.

Sorry for the delay in responding. I’m not sure why you’d need to delete and recreate the webhooks. The webhook system didn’t change with the deploy of the dashboard. The dashboard is/was just a front-end on an existing set of APIs. That being said, I’ll look into it.

Also in regards to the one webhook showing up in your dashboard and the other not, we’ll have to look into that as well.

I’ll get back to you.

Thanks!

@ScruffR Nope that did not help. We had previously tried using both the String() cast and C character array, but I went back and tried again with no success.

Can anyone with expertise in this area please help. Our project has now been on a nearly 2 week hold since we cannot get subscriptions to work with specific devices….

Hi @phippster

I was looking at the code on github for this and in particular the tests (since there are unit tests). The tests for the core-specific form always use a null event name to get all the events–maybe you could try that:

Spark.subscribe(NULL, getLogResponse, Spark.deviceID()); 

You then have more parsing work to do in the getLogResponse callback.

Sorry I can’t test this for you right now.

@bko I appreciate the idea. Tried it but that didn’t work either. We don’t get any data back from that option. I’m wondering if the device specific code was just never created for the webhook responses.

This sounds like a job for … super @Dave

Maybe he can have a look at the logs to see why these subscribes are not working for you.

Hi @phippster,

Interesting! Lets chat sometime about your product / use case, maybe we can tweak webhooks to work better for your use. At the moment a webhook belongs to your user account, not a specific device. One workaround might be to simply have the server respond with something like: thanks REQUESTING_CORE_ID, and then have all your devices listen to the response event, and ignore those that aren’t meant for them.

If you need a mass hook that replies to a specific device when triggered and not the user account, that’s slightly different than what I had imagined, but I suspect we can find a way to make that work as well. Do you want to PM me and we can arrange a chat / call sometime soon?

Thanks,
David

1 Like

Will do @Dave. Thanks.

1 Like

@phippster I am in the same situation than you are, I solved this with the ignore other deviceId way, But I don’t like this solution because if you have 50 cores you will get 49 request ignored and thats a lot of data and could case performance drop. Where you able to solve it with the help of @Dave?

@hcmx, Dave and I spoke about this situation and he’s on board with understanding and is working on the backend to make sure a core can get it’s own Web Hook response back without having to filter all the others. Glad to see another user with the same situation. @Dave is working on an update and we’ll update it here when it is released.

3 Likes

Hi,

@Dave Is there a solution for this yet?

Thanks

Hi @joe4465,

Sure, I think one solution would be to use responseTopic:

Thanks,
David

2 Likes

Thanks, I will give it a try.

Is there any documentation for responseTopic or a minimum example?

check the link Dave provided, there is a basic example using responseTopic

1 Like