首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FIWARE Orion Context Broker API V2 - accumulator-server.py

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

Stack Overflow用户
提问于 2018-05-24 15:47:33
回答 2查看 82关注 0票数 1

当我尝试使用下一个查询创建订阅时:

代码语言:javascript
复制
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

出现错误:

代码语言:javascript
复制
* 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"}

但是,如果我使用API的V1进行查询,则一切正常。我不知道为什么。请帮帮我!

EN

回答 2

Stack Overflow用户

发布于 2018-05-25 23:38:58

我已经用最新的Orion版本(1.13.0 +一些还没有发布的东西,目前只在master分支中)测试了你的相同请求,它可以工作:

代码语言:javascript
复制
$ 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
票数 0
EN

Stack Overflow用户

发布于 2022-01-08 12:30:26

解决方案:服务器累加器-server.py没有按照文档显示消息。在您运行orion的Docker中,您应该使用订阅者url是ipv6而不是locahost。因为在docker外部,localhost将不会被通知。

这是按订阅方式工作的

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50503798

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档