Fiware Orion CB subscriptions throttling - fiware-orion

I have created this subscription :
curl localhost:1026/v2/subscriptions -s -S -H 'Accept: application/json' | python -mjson.tool
[
{
"description": "Update room temperature",
"expires": "2020-04-05T14:00:00.00Z",
"id": "5b104ace028f2284c5517f51",
"notification": {
"attrs": [
"temperature"
],
"attrsFormat": "normalized",
"http": {
"url": "http://MyUrl/getSub"
},
"lastNotification": "2018-05-31T19:19:42.00Z",
"metadata": [
"5b019ae132232812eccb6d50",
"device",
"16",
"Auto",
"30",
"greater"
],
"timesSent": 1
},
"status": "active",
"subject": {
"condition": {
"attrs": [
"temperature"
]
},
"entities": [
{
"id": "5aff0eef23102126a4aeeea2",
"type": "room"
}
]
},
"throttling": 60
}
and even though I have set the throttling at 60 (1 minute if I understand it right), when I change the value of the temperature, orion sends me a notification even if the change happened before the one minute mark (for example I change the temperature value every 10 seconds). Shouldn't a notification be sent only if a change occurred after 60 seconds or am I understanding something wrong?

What you describe seems to be the right behaviour. I mean, if the subscription has a throttling of 60 seconds, you shouldn't receive any new notifiction until 60 seconds have passed from the previous one.
Possible causes:
You have another subscripion in place that is being triggered. But I understand this is not the case, as such subscription should be shown in the GET /v2/subscriptions result.
There is a bug in Orion which causes throttling to be ignored. In that case, it would be interesting to do the same test using a subscription created using NGSIv1 (using POST /v1/subscribeContext) in order to know the reach of the bug.

Related

Google task api due field

I am using google task list api and getting list from server. I created three task with different due time and date. I am getting date for every task but getting same due time. Can you please elaborate why this is happening?
Output:
{
"kind": "tasks#tasks",
"etag": "*********",
"items": [
{
"kind": "tasks#task",
"id": "******",
"etag": "******",
"title": "Task 2",
"updated": "2021-01-29T14:40:36.000Z",
"selfLink": "******",
"position": "00000000000000000001",
"status": "needsAction",
"due": "2021-01-30T00:00:00.000Z"
},
{
"kind": "tasks#task",
"id": "*********",
"etag": "*******",
"title": "Task 4",
"updated": "2021-01-29T13:18:51.000Z",
"selfLink": "*******",
"position": "00000000000000000000",
"status": "needsAction",
"due": "2021-01-30T00:00:00.000Z"
},
{
"kind": "tasks#task",
"id": "***********",
"etag": "*************",
"title": "Task 1",
"updated": "2021-01-29T13:08:39.000Z",
"selfLink": "*******",
"position": "00000000000000000002",
"status": "needsAction",
"due": "2021-01-29T00:00:00.000Z"
}
]
}
Based on the Resource:tasks,
Field: due
Due date of the task (as a RFC 3339 timestamp). Optional. The due date only records date information; the time portion of the timestamp is discarded when setting the due date. It isn't possible to read or write the time that a task is due via the API.
Google api can only read date not time for due field.
This line is from their official documentation Tasks API . tasks
Blockquote
"due": "A String", # Due date of the task (as a RFC 3339 timestamp). Optional. The due date only records date information; the time portion of the timestamp is discarded when setting the due date. It isn't possible to read or write the time that a task is due via the API.

FIWARE Orion: notification responses

In Orion I can create subscription:
curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
-d #- <<EOF
{
"description": "A subscription to get info about Room1",
"subject": {
"entities": [
{
"id": "Room1",
"type": "Room"
}
],
"condition": {
"attrs": [
"pressure"
]
}
},
"notification": {
"http": {
"url": "http://localhost:1028/accumulate"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
In this example, Orion will perform POST request on the server http://localhost:1028/accumulate. Is there a way to retrieve the response from the POST received by Orion? i.e. 200, 404...
In my use case the notifications perform POST requests to create some resources on another server. The POSTs returns the location of the created resources. It would be useful to retrieve those locations.
Orion doesn't record the responses to notifications it sends. It implements a "fire and forget" approach and pays little attention to the response of notification requests. Actually, Orion looks to the response of the last notification and uses it to set lastFailure or lastSuccess timestamp (depending the case) and setting status to failed if the response has an error code.
A workaround for your case could be achieved using a system in the middle. I mean, some bridging software that receives the notification from Orion, forwards to the final system, gets the response and does whatever processing should be do with such response (e.g. storing the location of the just created resource).

FIWARE Orion: return subscription id

When creating a subscription, it would be nice to return the subscription ID.
For instance, the following code doesn't return anything :
curl localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
-d #- <<EOF
{
"description": "A subscription to get info about Room1",
"subject": {
"entities": [
{
"id": "Room1",
"type": "Room"
}
],
"condition": {
"attrs": [
"pressure"
]
}
},
"notification": {
"http": {
"url": "http://localhost:1028/accumulate"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
In the subscription case, the resource id is generated server-side (with difference to the entities endpoint, where the id is decided client-side).
It would be nice to return it in the POST call, is there any way to do this?
Subscription ID is retrieved in Location header in the response to the subscription creation request, eg:
Location: /v2/subscriptions/5b991dfa12f473cee6651a1a
More details in the NGSIv2 API specification (check "Create Subscription" section).

How to identify health check request?

My app is getting health check about 10 health check request per hour, and that makes my conversation log messy.
Because of the health check does not have screen capability, our backend server response the request as Google Home is requesting.
Is there any way to detect if the request is health check request or not?
For starters, you should be responding as if it was a Google Home. You have to respond with valid output, or it will reject you. So don't try to be too fancy in your response - just use this to avoid cluttering your analytics and logs.
The health check will look like a normal welcome request. The ping will contain an argument named is_health_check with a boolValue of true and a textValue of 1. If you're using Dialogflow, this will be one of the arguments at originalRequest.data.inputs[0]. For the Actions SDK, it will be at data.inputs[0].
Here is a partial sample from Dialogflow:
{
"originalRequest": {
"source": "google",
"version": "2",
"data": {
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
}
]
},
"inputs": [
{
"rawInputs": [
{
"query": "Sample",
"inputType": "VOICE"
}
],
"arguments": [
{
"textValue": "1",
"name": "is_health_check",
"boolValue": true
}
],
"intent": "actions.intent.MAIN"
}
],
...
}

No Notification from Orion Context Broker

I am working with the Orion Context Broker and wanna get notifications for the following subscription, added to orion.lab.fiware.org:1026:
curl -v orion.lab.fiware.org:1026/v2/subscriptions -X POST -s -S --header 'Content-Type: application/json' --header "X-Auth-Token: <myToken>" -d #- <<EOF
{
"description": "A subscription to get info about Room1",
"subject": {
"entities": [
{
"id": "11582",
"type": "User"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"http": {
"url": "http://<myIPAddress>:8080"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
myToken: the token generated by the FIWARE server
myIPAddress: the IP address of my PC
However, in my sample HTTP server program (Node.js) on port 8080 I do not receive any notifications. I should note that after adding the above subscription, I add the entity with id 11582 through another POST request to orion.lab.fiware.org:1026/v2/entities.
When I read later the added subscription, it confirms that the notification has been sent (through lastNotification):
{
"id": "5768088c70dce43aa351cf9b",
"description": "A subscription to get info about Room1",
"expires": "2040-01-01T14:00:00.00Z",
"status": "active",
"subject": {
"entities": [
{
"id": "11582",
"idPattern": "",
"type": "User"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"timesSent": 1,
"lastNotification": "2016-06-20T15:16:04.00Z",
"attrs": [
"temperature"
],
"attrsFormat": "normalized",
"http": {
"url": "http://<myIPAddress>:8080"
}
},
"throttling": 5
}
Any idea why I do not receive the notification i my HTTP server program? My firewall is also off.
Thanks!
The following test has been donde in orion.lab.fiware.org. The termina1l.txt file shows the subscriptions and entity creation request sent to Orion (note we use localhost:10026, as the test has been done in the orion.lab.fiware.org host itself) and terminal2.txt file shows the notification received at the listener process (nc).
We have also done the same test (using UserTest2 type this time) running the listener on a VM machine at FIWARE Lab (which IP cannot be disclosed for security reasons) with the 1028 port openend in the Security Group and everything worked fine again, getting:
POST / HTTP/1.1
user-agent: orion/1.2.1 libcurl/7.19.7
host: 130.206.112.29:1028
accept: application/json
content-length: 146
content-type: application/json; charset=utf-8
fiware-correlator: 0870b41c-378d-11e6-910f-52540003a38e
ngsiv2-attrsformat: normalized
X-Forwarded-For: 127.0.0.1
Connection: keep-alive
{"subscriptionId":"5768ff6a70dce43aa351cfaa","data":[{"id":"11582","type":"UserTest2","temperature":{"type":"Float","value":23.5,"metadata":{}}}]}
Thus, I understand that something between orion.lab.fiware.org and your process is blocking the traffic. Note that apart for the firewall running in your machine (which you mention is off) another firewall layer could be blocking (e.g. FIWARE cloud or AWS cloud security group, coorporate firewalls, etc.)