我正在使用sth-comet's github repo的主分支(目前是2.0.0-next
的预发行版),我可以安装并执行它。当我想在上下文代理(v1.4.0)上创建订阅时,会出现此问题。这两种服务都安装在同一台FIWARE Lab机器上,我使用公共IP地址远程访问它们。
我一直在尝试使用documentation中提供的模板创建订阅,但STH总是抱怨FIWARE-Service
和FIWARE-ServicePath
标题(似乎是上下文代理不会在通知中发送它们。这是创建订阅的命令:
curl http://$(server):1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -H 'FIWARE-Service: default' -H 'FIWARE-ServicePath: /' -d @- <<EOF
{
"entities": [
{
"type": "weather.station",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature",
"humidity"
],
"reference": "http://$(server):8666/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"temperature",
"humidity"
]
}
],
"throttling": "PT5S"
}
EOF
这是报告的错误:
time=2016-10-06T15:56:30.124Z | lvl=WARN | corr=7220efae-8bdd-11e6-96a8-fa163ea89c59 | trans=11ef935c-f749-46b7-bcd4-942ffddedd27 | op=OPER_STH_POST | srv=default | subsrv=n/a | msg=POST /notify, event={"request":"1475769390111:robots:23181:ityixskh:10000","timestamp":1475769390123,"tags":["validation","error","headers"],"data":{"data":{"data":null,"isBoom":true,"isServer":false,"output":{"statusCode":400,"payload":{"statusCode":400,"error":"Bad Request","message":"child \"fiware-servicepath\" fails because [fiware-servicepath is required]"},"headers":{}}},"isBoom":true,"isServer":false,"output":{"statusCode":400,"payload":{"statusCode":400,"error":"Bad Request","message":"child \"fiware-servicepath\" fails because [fiware-servicepath is required]","validation":{"source":"headers","keys":[]}},"headers":{}}},"internal":true}
如果我使用上下文代理API的v2,我可以强制它发送FIWARE-Service
和FIWARE-ServicePath
标题:
curl http://$(server):1026/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -H 'FIWARE-Service: default' -H 'FIWARE-ServicePath: /' -d @- <<EOF
{
"description": "STH subscription",
"subject": {
"entities": [
{
"type": "weather.station",
"idPattern": ".*"
}
],
"condition": {
"attrs":[
"temperature",
"humidity"
]
}
},
"notification": {
"httpCustom": {
"url": "http://$(server):8666/notify",
"headers": {
"FIWARE-Service": "default",
"FIWARE-ServicePath": "/"
}
},
"attrs": [
"temperature",
"humidity"
]
},
"expires": "2018-04-05T14:00:00.00Z",
"throttling": 5
}
EOF
这样,STH服务器不符合标题,但会引发其他错误:
time=2016-10-06T15:46:57.564Z | lvl=ERROR | corr=19e59f02-8bdc-11e6-8534-fa163ea89c59 | trans=1b7fc29a-7f5c-449d-9238-d2e644154b05 | op=OPER_STH_POST | srv=default | subsrv=/ | msg=POST /notify, event={"request":"1475768812582:robots:8985:itycaq0o:10003","timestamp":1475768817564,"tags":["request","closed","error"],"internal":true}
time=2016-10-06T15:47:02.592Z | lvl=ERROR | corr=19e59f02-8bdc-11e6-8534-fa163ea89c59 | trans=7e5bf417-0b1d-4b53-b47b-838cead91b94 | op=OPER_STH_POST | srv=default | subsrv=/ | msg=POST /notify, event={"request":"1475768817606:robots:8985:itycaq0o:10004","timestamp":1475768822592,"tags":["request","closed","error"],"internal":true}
答案 0 :(得分:1)
首先,非常感谢您使用STH组件;)
如果服务路径是空的或默认的(即Fiware-ServicePath
),似乎该问题与Orion Context Broker在发送给STH组件的通知中不包括/
标头有关。 。我刚刚在Orion Context Broker存储库中创建了一个问题来处理它,以防你想跟踪它:https://github.com/telefonicaid/fiware-orion/issues/2584
如果您使用任何其他有效的服务路径,一切都应该没问题。
再次非常感谢你!
最好,Germán。