繁体   English   中英

Orion-LD 订阅问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM