我正在使用sth-comet 的 github repo的 master 分支(目前是 的预发行版2.0.0-next
),我能够安装和执行它。当我想在上下文代理(v1.4.0)上创建订阅时出现问题。这两项服务都安装在同一台 FIWARE Lab 机器上,我使用公共 IP 地址远程访问它们。
我一直在尝试使用您的文档中提供的模板创建订阅,但是 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}