fiware – Orion Context Broker – 按位置查询,没有元素

我正在使用Orion Context Broker的0.25.0版本.

如果我只使用上下文实体加载上下文代理,并且我将实体搜索到特定区域,那么一切似乎都可以正常工作:

(curl localhost:1026/v1/queryContext?limit=100 -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d  @- | python -mjson.tool) <<EOF
{
    "entities":[
        {
            "type":"Dispositivo_tmp",
            "isPattern":"true",
            "id":".*"
        }
    ],
    "restriction": {
        "scopes": [
            {
                "type": "FIWARE::Location",
                "value": {
                    "circle": {
                        "centerLatitude": "43.322361",
                        "centerLongitude": "-1.983222",
                        "radius": "1500"
                    }
                }
            }
        ]
    }
}
EOF

我得到了位于该区域的上下文实体的响应:

...
{
            "contextElement": {
                "attributes": [
                    {
                        "metadatas": [
                            {
                                "name": "location",
                                "type": "string",
                                "value": "WGS84"
                            }
                        ],
                        "name": "position",
                        "type": "coords",
                        "value": "43.3221, -1.9831"
                    },
                    {
                        "name": "pressure",
                        "type": "integer",
                        "value": "1"
                    },
                    {
                        "name": "temperature",
                        "type": "float",
                        "value": "25"
                    }
                ],
                "id": "CE_5.1",
                "isPattern": "false",
                "type": "Dispositivo_tmp"
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}

如果定义区域中没有元素,我会得到预期的响应:

{
    "errorCode": {
        "code": "404",
        "reasonPhrase": "No context element found"
    }
}

如果我也使用上下文注册加载上下文代理,则会出现问题.如果我在上下文代理上同时拥有上下文实体和上下文注册,并且我将上下文实体检查到我知道的区域是空的,我将不会得到任何响应,或者我会得到这个:

{
    "errorCode": {
        "code": "200",
        "reasonPhrase": "OK"
    }
}

似乎上下文代理中加载的上下文注册量越大,从系统获得(负)响应的时间就越长.

在同一场景中,如果我在具有元素的区域中查找上下文实体,则没有问题.在这种情况下,我会得到正确的答复.

这有什么意义吗?

谢谢

最佳答案 我已经看到这种行为是由于我在创建上下文注册时定义的URL.

网址不正确.因此,当上下文代理尝试使用提供的URL与设备联系时,它开始等待不会到达的答案.

我修改了URL并使用了’accumulate-server.py’虚拟测试服务器:

http://localhost:1028/accumulate

使用它,上下文代理获得一个中间响应并继续执行.

点赞