[英]Orion-LD Subscription Issues
我在 docker-compose 中將 Orion-LD:0.8.0 作為服務運行。
我想創建一個訂閱,每次在代理中創建type=Event的新實體時都會觸發該訂閱。 訂閱應該將 webhook 觸發到 docker-compose 中的另一個服務,這似乎不起作用。 我想知道這是否是我如何編寫訂閱或其他內容的問題。
從代理中的 get 請求返回的訂閱:
[
{
"id": "urn:ngsi-ld:Subscription:618397ade7b95210721ae0dd",
"type": "Subscription",
"description": "notify of new events",
"entities": [
{
"type": "Event"
}
],
"notification": {
"attributes": [
"id"
],
"format": "keyValues",
"endpoint": {
"uri": "http://anotherservice:1234/hook/events",
"accept": "application/json"
}
},
"@context": "linktocontext"
}
]
我有和你類似的問題。 也許問題在於,如果您使用 orion-ld,您應該使用"accept": "application/ld+json"
版本而沒有ld
。 但我不認為這是一個案例。
您使用的是 dockerize 版本的 orion 和您的應用程序嗎? 嘗試通過 docker 網絡連接它們。 就我而言,它是這樣的:
docker network connect docker_default orion_orion_1
其中 docker_default 取決於docker-compose.yml
設置。
其他可能性是您發布訂閱信息的方式。 我對實體進行訂閱的版本是(並且似乎有效):
subscription_body = {
"id": subscription_id,
"description": f"A subscription to get info about entity: entity",
"type": "Subscription",
"entities": [{"type": entity_type}],
"watchedAttributes": attribs,
"notification": {
"attributes": attribs,
"format": "normalized",
"endpoint": {
"uri": config['general']['url'],
"accept": "application/ld+json"
}
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 0,
"@context": ["linktocontext"]
}
response = requests.post(f"{config['general']['orion-server']}/ngsi-ld/v1/subscriptions",
data=json.dumps(subscription_body),
headers={'Content-type': 'application/ld+json'})
這個“type=Event”...“Event”將使用@context“linktocontext”進行擴展。 如果您創建一個帶有@context 的新實體,將“事件”擴展為其他內容,則訂閱將不會觸發任何通知,因為沒有匹配項。 也許這就是問題所在? [ application/json 或 application/ld+json 無所謂 ]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.