-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New section on Webhook message format #258
Comments
Before I make a PR about it, I would like to understand the requirements on the payload content for Webhook. I think that @benfrancis has more experience based on the comment at #126 (comment) . I am copying his proposal here:
This is already less than what is proposed, which has fields like |
Proposal:
E.g. {
"thingId": "https://mythingserver.com/things/mylamp1",
"event": "overheated",
"id": "223e3567-e89b-13d3-a456-426653",
"timestamp": "2021-11-16T16:53:50.817Z"
"data": 90
} Note that |
id's are used to distinguish and order events when they have the same timestamp. |
@benfrancis
|
@mlagally wrote:
Is it more important to be consistent with CloudEvents or to be consistent with other profiles? I thought we already agreed that being compliant with CloudEvents is not desirable, so there doesn't seem much point in partially aligning either.
IDs are not currently mandatory in the HTTP SSE Profile. They are mainly useful for catching up on missed events when re-establishing a connection, which doesn't apply in quite the same way to WebHooks.
I don't feel strongly about this one because I agree it isn't the most descriptive name, but it would at least be consistent with the HTTP SSE Profile.
That would be strange given that URL paths are not standardised in the profile. If you want to extend the WebHooks profile for observing properties you could define an alternative |
I note that defining a payload format for Webhooks has been deferred until the next version of the specification. How should Web Things serialise event data in WoT Profile 1.0 in this case? One very simple solution would be for Consumers to provide a different callback URL for each subscription which embeds the Thing ID and event name in the URL. That way the body of the POST request could directly contain the event data payload (serialised in JSON) without a wrapper, corresponding directly to the data schema of the EventAffordance. This would also address the kinds of concerns raised in #259 where WoT TD 1.1 Consumers which don't implement the profile don't understand the payload format because it doesn't directly map onto the data schema. |
@benfrancis I see the following alternatives:
|
It's not possible for WebHooks to be "compatible" with SSE since they are two completely different mechanisms, it's just a matter of whether we want some consistency in the naming of fields in the payloads across the two different profiles. Personally I think having some consistency between profiles will make the specification easier for developers to understand when implementing it, but it's not functionally necessary since the two different event mechanisms can not directly interoperate anyway. I thought we had already settled the debate on whether to re-use the CloudEvents specification, since it brings a lot of unnecessary redundancy of metadata which is already provided in a WoT Thing Description, and therefore unnecessarily increases the size of event payloads. I don't see any benefit of being partially consistent with CloudEvents, so we may as well define our own payload format which is internally consistent and is a better fit for the WoT data model. Either approach would be equally suitable for cloud-based deployments, I see no difference in use cases. For the sake of interoperability it would be preferable to define a single payload format for Webhooks. I do think defining a payload format is necessary for out-of-the-box interoperability, but not essential for WoT Profile 1.0 if the HTTP Webhook Profile is only informative. |
I note that in the W3C WebSub specification, metadata about Webhook event notifications or "distribution requests" (such as the topic URL) is provided in HTTP headers instead of in the body, so the body can be completely reserved for the event data (if any). Instead of trying to agree on a special JSON-based payload format for Webhook event notifications (and property observations) like the one I proposed above or the one used by CloudEvents, an alternative more minimalist approach would be to dedicate the whole body of the request to the property or event data (if any), and include event metadata in HTTP headers instead. E.g.
In the above example:
This is missing some information compared with my first proposal:
If any of those fields are considered essential, we could define custom HTTP headers for them, like the WebSub specification does. An advantage of dedicating the whole body of the event notification request to the property or event data is that the data schema of the property or event can be directly mapped onto the body of the request. This could be useful for Consumers which don't conform to the Profile (and therefore wouldn't know about a special payload format), since there's no way to declaratively define a data wrapper format for event notifications (or property observations) in a Form of a Thing Description. This would also be consistent with the HTTP SSE Profile where we use the whole data field of the text/event-stream format for the event data, rather than including any kind of wrapper around it. |
I think this needs addressing one way or another for Profile 1.0 |
Create a new section that defines the message format for Webhook events as a replacement for the current CloudEvents.
The text was updated successfully, but these errors were encountered: