Orion 无法从 IoTAgent 接收上下文通知:响应不正常

Orion failing to receive context notification from IoTAgent: response NOT OK

有点难以理解 IoTAgent-Orion 订阅将上下文信息发布到 Orion 出了什么问题。 Orion 服务健康检查正常,但未能收到响应 NOT OK 代码 404 的上下文。Orion 日志:

time=Thursday 28 Feb 14:25:57 2019.783Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 14:25:57 2019.783Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[592]:httpRequestSendWithCurl | msg=Sending message 3 to HTTP server: sending message of 576 bytes to HTTP server
time=Thursday 28 Feb 14:25:57 2019.791Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[612]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 14:25:57 2019.791Z | lvl=WARN | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[625]:httpRequestSendWithCurl | msg=Notification response NOT OK, http code: 404

编辑: 我再次编辑了我的问题以重现产生错误的场景。以下是代理日志:

time=2019-02-28T15:15:53.810Z | lvl=DEBUG | corr=bd797a30-3b6b-11e9-98a6-0242c0a85005 | trans=b725da6c-8917-4dde-9d29-defa97970b1a | op=IoTAgentNGSI.DomainControl | srv=smartgondor | subsrv=/gardens | msg=response-time: 8 | comp=IoTAgent
time=2019-02-28T15:16:00.398Z | lvl=DEBUG | corr=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | trans=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | op=IoTAgentNGSI.GenericMiddlewares | srv=n/a | subsrv=n/a | msg=Request for path [/iot/about] from [localhost:4041] | comp=IoTAgent
time=2019-02-28T15:16:00.399Z | lvl=DEBUG | corr=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | trans=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | op=IoTAgentNGSI.DomainControl | srv=n/a | subsrv=n/a | msg=response-time: 1 | comp=IoTAgent
time=2019-02-28T15:16:13.255Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=LWM2MLib.InformationReporting | srv=n/a | subsrv=n/a | msg=New data on resource /3303/0/5700 in device [1] | comp=IoTAgent
time=2019-02-28T15:16:13.255Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IOTAgent.LWM2MHandlers | srv=n/a | subsrv=n/a | msg=Handling data from device [raspiSensorTV] | comp=IoTAgent
.
.
time=2019-02-28T15:16:13.256Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Device"} | comp=IoTAgent
time=2019-02-28T15:16:13.260Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Device"}] | comp=IoTAgent
time=2019-02-28T15:16:13.260Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group","code":404} in get group device | comp=IoTAgent
.
.
time=2019-02-28T15:16:13.261Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Updating device value in the Context Broker at [http://orion:1026/v1/updateContext] | comp=IoTAgent
time=2019-02-28T15:16:13.261Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Using the following request:
{
    "url": "http://orion:1026/v1/updateContext",
    "method": "POST",
    "headers": {
        "fiware-service": "smartGondor",
        "fiware-servicepath": "/gardens"
    },
    "json": {
        "contextElements": [
            {
                "type": "Device",
                "isPattern": "false",
                "id": "Device:raspiSensorTV",
                "attributes": [
                    {
                        "name": "Temperature Sensor#0",
                        "type": "string",
                        "value": "�\u0016DA�\u0000\u0000",
                        "metadatas": [
                            {
                                "name": "TimeInstant",
                                "type": "ISO8601",
                                "value": "2019-02-28T15:16:13.261Z"
                            }
                        ]
                    },
                    {
                        "name": "TimeInstant",
                        "type": "ISO8601",
                        "value": "2019-02-28T15:16:13.261Z"
                    }
                ]
            }
        ],
        "updateAction": "UPDATE"
    }
}
 | comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Received the following request from the CB:
{
    "contextResponses": [
        {
            "contextElement": {
                "type": "Device",
                "isPattern": "false",
                "id": "Device:raspiSensorTV",
                "attributes": [
                    {
                        "name": "Temperature Sensor#0",
                        "type": "string",
                        "value": "",
                        "metadatas": [
                            {
                                "name": "TimeInstant",
                                "type": "ISO8601",
                                "value": "2019-02-28T15:16:13.261Z"
                            }
                        ]
                    },
                    {
                        "name": "TimeInstant",
                        "type": "ISO8601",
                        "value": ""
                    }
                ]
            },
            "statusCode": {
                "code": "200",
                "reasonPhrase": "OK"
            }
        }
    ]
}
 | comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Value updated successfully | comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IOTAgent.LWM2MHandlers | srv=n/a | subsrv=n/a | msg=Data handled successfully | comp=IoTAgent
time=2019-02-28T15:16:13.282Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.GenericMiddlewares | srv=smartgondor | subsrv=/gardens | msg=Request for path [/publish] from [lightweightm2m-iotagent:4041] | comp=IoTAgent
time=2019-02-28T15:16:13.282Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.GenericMiddlewares | srv=smartgondor | subsrv=/gardens | msg=Body:
{
    "subscriptionId": "5c77fb29a23ec2205a00b013",
    "data": [
        {
            "id": "Device:raspiSensorTV",
            "type": "Device",
            "Temperature Sensor#0": {
                "type": "string",
                "value": "�\u0016DA�\u0000\u0000",
                "metadata": {
                    "TimeInstant": {
                        "type": "ISO8601",
                        "value": "2019-02-28T15:16:13.261Z"
                    }
                }
            }
        }
    ]
}
 | comp=IoTAgent
time=2019-02-28T15:16:13.283Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.DomainControl | srv=smartgondor | subsrv=/gardens | msg=response-time: 4 | comp=IoTAgent

代理日志中报告了这种情况,而 Orion 日志显示如下:

time=Thursday 28 Feb 15:16:13 2019.269Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction from 192.168.80.4:52068/v1/updateContext
time=Thursday 28 Feb 15:16:13 2019.269Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=rest.cpp[885]:servicePathSplit | msg=Service Path 0: '/gardens'
time=Thursday 28 Feb 15:16:13 2019.271Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=connectionOperations.cpp[94]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "Device:raspiSensorTV", _id.type: "Device", _id.servicePath: { $in: [ /^/gardens$/ ] } })
time=Thursday 28 Feb 15:16:13 2019.272Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=connectionOperations.cpp[449]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "Device:raspiSensorTV", _id.type: "Device", _id.servicePath: { $in: [ /^/gardens$/ ] } }, { $set: { attrs.Temperature Sensor#0: { value: "�DA�>)
time=Thursday 28 Feb 15:16:13 2019.273Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 15:16:13 2019.273Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1874]:lmTransactionEnd | msg=Transaction ended
time=Thursday 28 Feb 15:16:13 2019.274Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[592]:httpRequestSendWithCurl | msg=Sending message 2 to HTTP server: sending message of 573 bytes to HTTP server
time=Thursday 28 Feb 15:16:13 2019.284Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[612]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 15:16:13 2019.284Z | lvl=WARN | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[625]:httpRequestSendWithCurl | msg=Notification response NOT OK, http code: 404
time=Thursday 28 Feb 15:16:13 2019.285Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1874]:lmTransactionEnd | msg=Transaction ended

我提交以下 IoTAgent-Orion 订阅请求:

$curl -iX POST localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
    --header 'Accept: application/json' --header 'fiware-service: smartGondor' --header 'fiware-servicepath: /gardens' -d'
{
  "subject": {
    "entities": [
    {
        "idPattern": ".*",
        "type": "Device"
    }
    ],
    "condition": {
        "attrs": [ "Temperature Sensor#0" ]
    }
  },
  "notification": {
    "http": {
        "url": "http://lightweightm2m-iotagent:4041/publish"
    },
    "attrs": [ "Temperature Sensor#0" ]
  }
}'

幸运的是,尽管此错误仍然出现,但它现在可以正常工作。至少它在工作,不用担心。