Fiware 猎户座CB不';更新物联网代理上的惰性属性

Fiware 猎户座CB不';更新物联网代理上的惰性属性,fiware,fiware-orion,Fiware,Fiware Orion,我正在尝试使用Orion CB作为IoT代理的Contex提供程序,在该代理中,我只注册了具有惰性属性的设备 在IoT代理上,我需要处理updateContext请求,因此我对这些请求做了如下处理: iotAgentLib.setDataUpdateHandler(updateContextHandler); 在updateContextHandler函数中,我只有一条指令: console.log(attributes); 以查看是否已正确接收到我要更新的所有值 现在,如果我对设备表示的实

我正在尝试使用Orion CB作为IoT代理的Contex提供程序,在该代理中,我只注册了具有惰性属性的设备

在IoT代理上,我需要处理updateContext请求,因此我对这些请求做了如下处理:

iotAgentLib.setDataUpdateHandler(updateContextHandler);
在updateContextHandler函数中,我只有一条指令:

console.log(attributes);
以查看是否已正确接收到我要更新的所有值

现在,如果我对设备表示的实体的一个属性进行更新:

curl -i -X POST \
-H "fiware-service:service1" \
-H "fiware-servicepath:/subservice1" \
-H "X-Auth-Token:wNRwDwqYlLoLD8U9sFkTAEE6PfYMbQ" \
-H "Content-Type:application/json" \
-d \
'{
    "contextElements": [
        {
            "id": "ncc_estimate",
            "attributes": [
                {
                    "name": "arrival",
                    "type": "string",
                    "value": "some_value"
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
} ' \
'http://{orion_address}/v1/updateContext'
我在物联网代理输出控制台上看到的是:

time=2018-01-09T08:14:59.539Z | lvl=DEBUG | corr=2f4fdb0c-f515-11e7-86b2-0242ac110003 | trans=6ac5c35d-d7bf-419c-8f64-bc843b991d47 | op=IoTAgentNGSI.GenericMiddlewares | srv=service1 | subsrv=/subservice1 | msg=Body:

{
    "contextElements": [
        {
            "type": "nccestimate",
            "isPattern": "false",
            "id": "ncc_estimate",
            "attributes": [
                {
                    "name": "arrival",
                    "type": "string",
                    "value": ""
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
}
如您所见,value字段为空,我也可以从UpdateHandler函数中的console.log()输出中看到,即:

[ { name: 'arrival', type: 'string', value: '' } ]
Orion似乎正在删除该值,然后再将其发送给IoT代理。有什么问题吗?我做错什么了吗

编辑:

下面是对:/v1/registry/contextenties/ncc\u estimate调用的响应

{"contextRegistrationResponses":[
    {"contextRegistration":
        {"entities":[
            {
                "type":"nccestimate",
                "isPattern":"false",
                "id":"ncc_estimate"
            }
        ],
        "attributes":[
            {
                "name":"transport_type",
                "type":"string",
                "isDomain":"false"
            },
            {
                "name":"arrival",
                "type":"string",
                "isDomain":"false" 
           }
        ],
        "providingApplication":"http://192.168.199.151:4044"}
    }
]}
编辑2:

这是Orion在执行前面描述的updateContext操作时发送给iot代理的内容:

POST //updateContext HTTP/1.1
User-Agent: orion/1.10.0-next libcurl/7.19.7
Host: 192.168.199.151:4044
fiware-service: service1
Fiware-ServicePath: /subservice1
X-Auth-Token: M62UkJc7yKX5aQwaHrsODfIrV4Ou85
Accept: application/json
Content-length: 169
Content-type: application/json; charset=utf-8
Fiware-Correlator: 42561e9a-f615-11e7-8610-0242ac110003

{"contextElements":[{"type":"nccestimate","isPattern":"false","id":"ncc_estimate","attributes":[{"name":"arrival","type":"string","value":""}]}],"updateAction":"UPDATE"}
如您所见,属性的“值”字段为空。
我使用的是Orion版本1.10.0和iot代理节点库版本2.5.1。

我使用与您相同的版本(即1.10.0)完成了以下测试

首先,创建IOTA将创建的注册:

(curl -s -S localhost:1026/v1/registry/registerContext -H "fiware-service:service1" -H "fiware-servicepath:/subservice1" -H 'Content-Type: application/json' -d @- | python -mjson.tool) <<EOF
{
    "contextRegistrations": [
        {
            "entities": [
                {
                    "type": "nccestimate",
                    "isPattern": "false",
                    "id": "ncc_estimate"
                }
            ],
            "attributes": [
                {
                    "name": "transport_type",
                    "type": "string",
                    "isDomain": "false"
                },
                {
                    "name": "arrival",
                    "type": "string",
                    "isDomain": "false"
                }
            ],
            "providingApplication": "http://localhost:4044"
        }
    ],
    "duration": "P1M"
}
EOF
哪种反应是正确的

{
    "contextRegistrationResponses": [
        {
            "contextRegistration": {
                "attributes": [
                    {
                        "isDomain": "false",
                        "name": "transport_type",
                        "type": "string"
                    },
                    {
                        "isDomain": "false",
                        "name": "arrival",
                        "type": "string"
                    }
                ],
                "entities": [
                    {
                        "id": "ncc_estimate",
                        "isPattern": "false",
                        "type": "nccestimate"
                    }
                ],
                "providingApplication": "http://localhost:4044"
            }
        }
    ]
}
接下来,在本地主机上的
providingApplication
端口上运行
nc
进程

nc -l -p 4044
设置完成后,让我们首先根据问题中的更新进行测试

curl -s -S -X POST http://localhost:1026/v1/updateContext -H "fiware-service:service1" -H "fiware-servicepath:/subservice1" -H "Content-Type:application/json" -d @- <<EOF
{
    "contextElements": [
        {
            "id": "ncc_estimate",
            "attributes": [
                {
                    "name": "arrival",
                    "type": "string",
                    "value": "some_value"
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
}
EOF
换句话说,Orion没有转发响应。我不知道为什么在你的情况下会被转发并在IOTA日志文件中留下痕迹

下一个测试使用相同的请求,但为实体添加一个
类型
字段

curl -s -S -X POST http://localhost:1026/v1/updateContext -H "fiware-service:service1" -H "fiware-servicepath:/subservice1" -H "Content-Type:application/json" -d @- <<EOF
{
    "contextElements": [
        {
            "id": "ncc_estimate",
            "type": "nccestimate",
            "attributes": [
                {
                    "name": "arrival",
                    "type": "string",
                    "value": "some_value"
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
}
EOF
注意响应中的
某些值。在这种情况下,Orion似乎正在正确地处理请求

编辑:根据用户反馈,实体
type
解决了问题。我们在以下方面强调了这一点:

您应该在查询/更新中包括实体类型,以便ContextBroker能够转发到上下文提供程序


惰性属性基于IOTA在配置时在CB创建的注册。这将是一个非常有用的信息来发现可能发生的事情。请检查与设备相关的CB注册(请参阅了解如何在CB发现现有注册),并编辑您的问题帖子以将其包括在内。谢谢!我已经补充了你的要求,希望能有所帮助。谢谢。注册似乎没问题,它包含了懒惰属性。让我们检查猎户座实际发送的是什么,以丢弃物联网日志系统中的一个bug。要做到这一点,只需在配置设备后停止IOTA,它们就可以在同一端口启动侦听器进程(如
nc
netcat
)。然后,更新CB处的属性,并检查在listner过程中得到了什么。请编辑包含该信息的问题帖子。此外,如果您在问题帖子中添加有关正在使用的IOTA和Orion版本的信息,那将非常好。我已经添加了您要求的内容。正如你所看到的,Orion没有向IoT代理发送任何值。请看一下我在回复帖子中描述的测试,它模拟了你的情况。然而,我得到的结果并不完全相同。我建议:1)在CB中运行相同的测试步骤“脚本”(首先清理数据库),2)尝试将实体类型添加到更新中(在CB-IOTA设置中)。谢谢,在更新请求中引入“类型”字段解决了问题。感谢反馈!我们修改了文档以使其更清晰(见底部)。
{
    "contextResponses": [{
        "contextElement": {
            "type": "",
            "isPattern": "false",
            "id": "ncc_estimate",
            "attributes": [{
                "name": "arrival",
                "type": "string",
                "value": ""
            }]
        },
        "statusCode": {
            "code": "404",
            "reasonPhrase": "No context element found",
            "details": "ncc_estimate"
        }
    }]
}
curl -s -S -X POST http://localhost:1026/v1/updateContext -H "fiware-service:service1" -H "fiware-servicepath:/subservice1" -H "Content-Type:application/json" -d @- <<EOF
{
    "contextElements": [
        {
            "id": "ncc_estimate",
            "type": "nccestimate",
            "attributes": [
                {
                    "name": "arrival",
                    "type": "string",
                    "value": "some_value"
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
}
EOF
POST //updateContext HTTP/1.1
User-Agent: orion/1.10.0 libcurl/7.38.0
Host: localhost:4044
fiware-service: service1
Fiware-ServicePath: /subservice1
Accept: application/json
Content-length: 179
Content-type: application/json; charset=utf-8
Fiware-Correlator: 42e75f8a-fa0d-11e7-93f1-000c29173617

{"contextElements":[{"type":"nccestimate","isPattern":"false","id":"ncc_estimate","attributes":[{"name":"arrival","type":"string","value":"some_value"}]}],"updateAction":"UPDATE"}