Notifications Fiware Orion上下文代理订阅通知问题

Notifications Fiware Orion上下文代理订阅通知问题,notifications,subscription,fiware,fiware-orion,broker,Notifications,Subscription,Fiware,Fiware Orion,Broker,我正在使用orion上下文代理GE image orion-psb-image-R5.4版本1.7.0,并在其中注册了一个设备实体,然后在raspberry pi简单python服务器脚本中实现,该脚本侦听任何传入消息并将其打印到pi的日志中。然后,我向上下文代理发送了一条订阅消息,让我的raspberry pi订阅上下文代理中相应的实体。问题是,每当我在上下文代理中更新实体中的条件属性时,它们都应该触发对raspberry pi的通知,然后pi中的服务器脚本在pi的日志中打印通知。但实际情况是

我正在使用orion上下文代理GE image orion-psb-image-R5.4版本1.7.0,并在其中注册了一个设备实体,然后在raspberry pi简单python服务器脚本中实现,该脚本侦听任何传入消息并将其打印到pi的日志中。然后,我向上下文代理发送了一条订阅消息,让我的raspberry pi订阅上下文代理中相应的实体。问题是,每当我在上下文代理中更新实体中的条件属性时,它们都应该触发对raspberry pi的通知,然后pi中的服务器脚本在pi的日志中打印通知。但实际情况是,上下文代理可能会多次触发通知,然后在对条件属性应用任何其他更改时突然停止发送任何通知,在每次尝试时,我都会在上下文代理中检索订阅状态,并发现lastfailure属性声明了一个失败,该属性给出了我上次失败尝试的时间。 我认为问题可能是到我的Pi的连接,甚至是服务器脚本本身,但当我从终端向raspberry Pi发出直接请求时,它会立即打印所有消息,即使是从远程位置进行更新。所以我得出结论,问题肯定出在上下文代理和订阅本身的通知过程上

以下是我提出的订阅请求:

curl -v contextbrokeraddress:1026/v2/subscriptions -s -S --header "Fiware-Service: XYZ" --header "Fiware-ServicePath: /XYZ" --header 'Content-Type: application/json' \
    -d @- <<EOF
{
  "description": " Try",
  "subject": {
    "entities": [
      {
        "id": "Controller1",
        "type": "Controller"
      }
    ],
    "condition": {
      "attrs": [
        "switch",
        "datashow"

      ]
    }
  },
  "notification": {
    "http": {
      "url": "http://raspberryPiaddress:8080"
    },
    "attrs": [
     "switch",
     "datashow"
    ]
  },
  "expires": "2040-01-01T14:00:00.00Z",
  "throttling": 5
}
EOF
这就是来自上下文代理的通知在Pi的成功时间打印在其日志上的方式:

listening on port 8080
notified
POST / HTTP/1.1
User-Agent: orion/1.7.0 libcurl/7.19.7
Host: raspberryPiaddress:8080
fiware-service: XYZ
Fiware-ServicePath: /XYZ
X-Auth-Token: token
Accept: application/json
Content-length: 208
Content-type: application/json; charset=utf-8
Fiware-Correlator: f48ced60-1069-11e7-b743-fa163e7c4daf
Ngsiv2-AttrsFormat: normalized

{"subscriptionId":"58cd49191e9c000de6ea89c7","data":[{"id":"Controller1","type":"Controller","switch":{"type":"command","value":"OFF","metadata":{}},"datashow":{"type":"string","value":"OFF","metadata":{}}}]}
当实体上的任何后续更新都没有收到通知时,我通过检索订阅状态来检查它是否失败,订阅状态表示在我尝试发送通知的准确时间,上下文代理中发生了失败。这是我检索的状态,以检查:

[
    {
        "description": " Try",
        "expires": "2040-01-01T14:00:00.00Z",
        "id": "58cd49191e9c000de6ea89c7",
        "notification": {
            "attrs": [
                "switch",
                "datashow"
            ],
            "attrsFormat": "normalized",
            "http": {
                "url": "http://ahmadpi.ddns.net:8080"
            },
            **"lastFailure": "2017-03-24T08:22:23.00Z",**
            "lastNotification": "2017-03-24T08:22:18.00Z",
            "lastSuccess": "2017-03-23T22:09:33.00Z",
            "timesSent": 66
        },
        "status": "failed",
        "subject": {
            "condition": {
                "attrs": [
                    "switch",
                    "datashow"
                ]
            },
            "entities": [
                {
                    "id": "Controller1",
                    "type": "Controller"
                }
            ]
        },
        "throttling": 5
    }
]

现在的问题似乎与上下文代理及其内部处理订阅/通知过程的方式有关。现在,我想知道问题是与我使用的上下文代理映像版本有关,还是与其他方面有关。我只是想知道问题出在哪里,以及如何处理,非常感谢

虽然我不能完全确定as没有所有的输入(特别是CB日志跟踪),但我倾向于认为是网络/连接问题,“它工作得很好,正如我所说,但有时会因为某些原因停止”(见问题帖子中的评论线程),与Orion Context Broker没有直接关系。

由于实体更新,Context Broker日志文件(通常位于
/var/log/contextBroker/contextBroker.log
)中是否有任何日志跟踪?在这种情况下,请编辑您的问题帖子以包含它们。谢谢此外,请编辑您的问题帖子,以说明每次更新尝试之间经过的时间。考虑到您的订阅有5秒的限制,该信息是相关的。谢谢通知可能会被触发一次或多次,但上下文代理突然无法发送其他通知。到目前为止,我所观察到的是,当我在节流时间过去之前更新condition属性时,上下文代理可能会失败,因此在这种情况下,上下文代理完全失败,我需要重新启动服务器以再次接受通知。上下文代理会因为@fgalan的这种态度而失败吗?我有点困惑,因为你在最后一条评论中描述的案例与问题帖子中的不一致。我的意思是,在问题帖子中,您提到“它可能只会第一次触发对raspberry pi的通知,但随后在任何尝试[更新属性值]时失败”。我的意思是,没有提到更新条件属性。请查看您的问题帖子并进行编辑以适应实际发生的情况,包括所有需要的信息(例如订阅更新请求、属性更新时的日志跟踪等)。让我们尝试删除熵=让我们尝试让事情变得更简单:)
[
    {
        "description": " Try",
        "expires": "2040-01-01T14:00:00.00Z",
        "id": "58cd49191e9c000de6ea89c7",
        "notification": {
            "attrs": [
                "switch",
                "datashow"
            ],
            "attrsFormat": "normalized",
            "http": {
                "url": "http://ahmadpi.ddns.net:8080"
            },
            **"lastFailure": "2017-03-24T08:22:23.00Z",**
            "lastNotification": "2017-03-24T08:22:18.00Z",
            "lastSuccess": "2017-03-23T22:09:33.00Z",
            "timesSent": 66
        },
        "status": "failed",
        "subject": {
            "condition": {
                "attrs": [
                    "switch",
                    "datashow"
                ]
            },
            "entities": [
                {
                    "id": "Controller1",
                    "type": "Controller"
                }
            ]
        },
        "throttling": 5
    }
]