简体   繁体   English

FIWARE Orion Context Broker API V2 - accumulator-server.py

[英]FIWARE Orion Context Broker API V2 - accumulator-server.py

When I try to create a subscription using the next query:当我尝试使用下一个查询创建订阅时:

curl -v localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' -d @- <<EOF
{
   "description": "A subscription to get info about Room1",
   "subject": {
     "entities": [
       {
         "id": "Room10",
         "type": "Room"
       }
     ],
     "condition": {
       "attrs": ["pressure"]
     }
   },
   "notification": {
     "http": {
       "url": "http://localhost:1028/publish"
     },
     "attrs": ["temperature"]
   },
   "expires": "2040-01-01T14:00:00.00Z",
   "throttling": 5
}
EOF

An error occurs:发生错误:

* About to connect() to localhost port 1026 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 1026 (#0)
> POST /v2/subscriptions HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost:1026
> Accept: */*
> Content-Type: application/json
> Content-Length: 376
> 
< HTTP/1.1 400 Bad Request
< Connection: Keep-Alive
< Content-Length: 72
< Content-Type: application/json
< Date: Thu, 24 May 2018 07:38:32 GMT
< 
* Connection #0 to host localhost left intact
* Closing connection #0
{"error":"BadRequest","description":"no condition attributes specified"}

However, if I make the query using the V1 of the API all work right.但是,如果我使用 API 的 V1 进行查询,一切正常。 I do not know why.我不知道为什么。 Please help me!请帮我!

I have tested your same request with a recent Orion version (1.13.0 + some not yet released stuff only in master branch at the present moment) and it works: 我已经使用最新的Orion版本(1.13.0 +目前仅在master分支中尚未发布的内容)测试了您的相同请求,并且它可以正常工作:

$ curl -v localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' -d @- <<EOF
> {
>    "description": "A subscription to get info about Room1",
>    "subject": {
>      "entities": [
>        {
>          "id": "Room10",
>          "type": "Room"
>        }
>      ],
>      "condition": {
>        "attrs": ["pressure"]
>      }
>    },
>    "notification": {
>      "http": {
>        "url": "http://localhost:1028/publish"
>      },
>      "attrs": ["temperature"]
>    },
>    "expires": "2040-01-01T14:00:00.00Z",
>    "throttling": 5
> }
> EOF
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 1026 (#0)
> POST /v2/subscriptions HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost:1026
> Accept: */*
> Content-Type: application/json
> Content-Length: 400
> 
* upload completely sent off: 400 out of 400 bytes
< HTTP/1.1 201 Created
< Connection: Keep-Alive
< Content-Length: 0
< Location: /v2/subscriptions/5b082dc2c17960f8773dd74d
< Fiware-Correlator: 8dd38278-6031-11e8-b6dc-000c29173617
< Date: Fri, 25 May 2018 15:37:38 GMT
< 
* Connection #0 to host localhost left intact

Solution : The Server accumulator-server.py is not showing message as per documentation .解决方案:服务器 accumulator-server.py 未按照文档显示消息。 In Docker where your orion is running , you should use subscriber url is ipv6 not locahost .在运行 orion 的 Docker 中,您应该使用订阅者 url 是 ipv6 而不是 locahost。 Because outside docker , localhost will not be notified .因为在 docker 之外,不会通知 localhost。

This is working as per the subscription这是按照订阅工作的

https://github.com/telefonicaid/fiware-orion/issues/3570#issuecomment-1007966810 https://github.com/telefonicaid/fiware-orion/issues/3570#issuecomment-1007966810

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM