【发布时间】:2023-01-19 19:40:43
【问题描述】:
我不明白为什么 Orion 说要成功发送 TrafficFlowObserved 实体更新,但我的服务(dockerized)什么也没收到。
我预计会出现以下情况之一:
- 如果 Orion 联系服务失败,假设 url 不正确,或者
- 我的服务处理请求并将负载打印到控制台。
但这两种情况都没有发生。
这是 Orion 的日志:
2023-01-18 14:16:50 time=Wednesday 18 Jan 13:16:50 2023.790Z | lvl=TMP | corr=N/A | trans=1674046401-299-00000017019 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[564]:httpRequestSendWithCurl | msg=Sending message 16973 to HTTP server: sending message of 994 bytes to HTTP server
2023-01-18 14:16:50 time=Wednesday 18 Jan 13:16:50 2023.792Z | lvl=INFO | corr=N/A | trans=1674046401-299-00000017019 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[587]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://smart-vertical:9090/subscription/traffic-flow/observation?subscriptionId=urn:ngsi-ld:Subscription:59c301f4-972f-11ed-809c-0242ac190006
这是 Quarkus 中应该接收通知的资源代码:
@Path("/subscription/traffic-flow")
public class TrafficFlowResource {
@POST
@Path("/observation")
@Consumes(MediaType.APPLICATION_JSON)
public void measurement(@QueryParam("subscriptionId") String id, Payload payload) {
logger.info(payload);
}
}
Orion Context Broker 订阅如下所示,但它是以编程方式完成的:
curl -L -X POST 'http://localhost:1026/ngsi-ld/v1/subscriptions/' \
-H 'Content-Type: application/ld+json' \
-H 'NGSILD-Tenant: openiot' \
--data-raw '{
"description": "Notify me of all traffic flow observation changes",
"type": "Subscription",
"entities": [{"type": "TrafficFlowObserved"}],
"watchedAttributes": [
"averageVehicleSpeed",
"intensity",
"occupancy",
"levelOfService",
"roadLoad",
"saturationFlow"
],
"notification": {
"format": "keyValues",
"endpoint": {
"uri": "http://smart-vertical:9090/subscription/traffic-flow/observation",
"accept": "application/json"
}
},
"@context": "http://ld-context:80/ngsi-context.jsonld"
}'
这是 docker 中的服务配置:
smart-vertical:
build:
context: ./smart-vertical
dockerfile: src/main/docker/Dockerfile.jvm
restart: on-failure
depends_on:
- orion
expose:
- "9090"
ports:
- "9090:9090"
environment:
- CB_HOST=orion
- CB_PORT=1026
- SMART_VERTICAL_PORT=9090
- SMART_VERTICAL_HOST=http://smart-vertical:9090/subscription
- NGSI_CONTEXT_URL=http://ld-context:80/ngsi-context.jsonld
Orion 和所有服务都在 docker 自动创建的同一个网络上。
我觉得这是一个 IP 问题,但如果没有错误消息,我无法确定。
我所做的测试是更改 ip,因此我没有在 docker-compose.yaml 中使用“smart-vertical”,而是尝试了“localhost”、172.30.0.8(由 docker 设置)、0.0.0.0,但是情况变得更糟,因为我得到以下结果:
2023-01-18 14:55:44 time=Wednesday 18 Jan 13:55:44 2023.079Z | lvl=ERROR | corr=N/A | trans=1674050062-123-00000000379 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[573]:httpRequestSendWithCurl | msg=curl_easy_perform failed: 7
或者
2023-01-18 15:07:43 time=Wednesday 18 Jan 14:07:43 2023.747Z | lvl=ERROR | corr=N/A | trans=1674050827-980-00000000194 | from=pending | srv=pending | subsrv=pending | comp=Orion | op=httpRequestSend.cpp[573]:httpRequestSendWithCurl | msg=curl_easy_perform failed: 28
从 Orion 实现 (github) 我看到:
- 7 代表邮件大小太大
- 28应该是2+8??其中 2 代表“无效 IP”,8 代表“无法初始化 libcurl(注意:仅当实际 curl 未作为第一个参数提供时才有可能)”。
Quarkus 使用 Vertx,默认情况下 Vertx 使用自己的 DNS,这可能是问题所在吗?但我不明白为什么要使用此设置
SMART_VERTICAL_HOST=http://smart-vertical:9090/subscription
我没有 IP 问题,但我仍然没有收到任何东西。
【问题讨论】:
标签: docker docker-compose fiware docker-networking fiware-orion