Orion Context Broker Fiware中的订阅 [英] Subscription in Orion Context Broker Fiware

查看:86
本文介绍了Orion Context Broker Fiware中的订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试向我的Orion Context Broker实例发送订阅.我正在发送此JSON:

I try to send a subscription to my Orion Context Broker instance. I'm sending this JSON:

{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}

然后我收到下一条消息:

And I receive the next message:

<subscribeContextResponse>
  <subscribeError>
    <errorCode>
      <code>400</code>
      <reasonPhrase>Bad Request</reasonPhrase>
      <details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
    </errorCode>
  </subscribeError>
</subscribeContextResponse>

我将它使用的所有属性放在 Orion Context Broker网络研讨会-演示第2部分我可以看到其他名为Throttling的属性,但在文档中却没有看到.

I put all attributes that it is using in the documentation. But in the webinar Orion Context Broker Webinar - Demo part 2 I can see other attribute called Throttling, but I don't see in the documentation.

我在做什么不好?

谢谢.

推荐答案

我已经测试了您的请求(复制粘贴),这就是结果(使用Orion 0.17.0).

I have tested with your request (copy-pasted) and this is the result (with Orion 0.17.0).

命令(您可以检查有效载荷是否与您使用的有效载荷相同)

Command (you can check that the payload is exactly the one you used):

(curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
  "duration": "P1M",
  "reference": "http://130.206.127.23:1026/ngsi10/notifyContext",
  "notifyConditions": [
    {
      "condValues": [
        "PT10s"
      ],
      "type": "ONTIMEINTERVAL"
    }
  ],
  "entities": [
    {
      "id": "1.0",
      "type": "Capsule",
      "isPattern": "false"
    }
  ],
  "attributes": [
    "temperature"
  ]
}
EOF

结果:

{
    "subscribeResponse": {
        "duration": "P1M", 
        "subscriptionId": "5489e0bfe5007d3271ab5a61"
    }
}

因此,我的测试还可以,所以我倾向于认为该问题与编码有关,并且未在您的问题帖子中显示,例如的用法(错误的" intead)以及类似内容.

Thus, my test was ok so I tend to think that the problem is related with encoding and it is not shown in your question post, e.g. the usage of " (wrong) intead of " and things like that.

另一个常见的问题来源是使用脚本文件,该脚本文件包含"DOS文本"中CB的curl请求(通常是由于使用DOS/Windows文本编辑器).如果您运行file yourfile.sh并获取以下内容,则可以轻松检测到此情况

another common source of problems is using script files containing the curl request to CB in "DOS text" (typically due to the usage of DOS/Windows text editors). This can be easility detected if you run file yourfile.sh and get the following

yourfile.sh: ASCII text, with CRLF line terminators

代替以下

yourfile.sh: ASCII text

解决方案非常简单:例如使用dos2unix命令行工具将文件转换为"Unix文本".

The solution is quite simple: transform the file to "Unix text", for example using the dos2unix command line tool.

这篇关于Orion Context Broker Fiware中的订阅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆