繁体   English   中英

Orion-LD 的订阅失败并出现 Mongo-DB 错误

[英]Subscription at Orion-LD fails with Mongo-DB error

我尝试从 Orion-LD 订阅 Quantum Leap 和 CrateDB 运行。 不幸的是,似乎 MongDB 在尝试访问订阅时抛出错误Error (string field 'csf' is missing in BSONObj or Error (string field 'name' is missing in BSONObj' 。结果是数据不能传递给 Quantum Leap 进行进一步处理。

...
time=Friday 24 Jun 11:03:59 2022.081Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=safeMongo.cpp[145]:getStringField | msg=Runtime Error (string field 'name' is missing in BSONObj <{ _id: "urn:ngsi-ld:Subscription:62b578ea4567412cdf07306e", expiration: 2147483647.0, reference: "http://172.18.1.5:8668/v2/notify", custom: false, mimeType: "application/json", throttling: 0.0, servicePath: "/", description: "Notify me of temperature", status: "active", entities: [ { id: "", isPattern: "", type: "https://uri.fiware.org/ns/data-models#WeatherObserved", isTypePattern: false } ], attrs: [ "https://uri.fiware.org/ns/data-models#temperature" ], metadata: [], blacklist: false, ldContext: "http://172.18.1.2/datamodels.context-ngsi.jsonld", createdAt: 1656060138.058298, modifiedAt: 1656060138.058298, conditions: [ "https://uri.fiware.org/ns/data-models#temperature" ], expression: { q: "https://uri=fiware=org/ns/data-models#temperature<100", mq: "", geometry: "", coords: "", georel: "", geoproperty: "" }, format: "normalized" }> from caller setName:280)
time=Friday 24 Jun 11:03:59 2022.081Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=safeMongo.cpp[145]:getStringField | msg=Runtime Error (string field 'csf' is missing in BSONObj <{ _id: "urn:ngsi-ld:Subscription:62b578ea4567412cdf07306e", expiration: 2147483647.0, reference: "http://172.18.1.5:8668/v2/notify", custom: false, mimeType: "application/json", throttling: 0.0, servicePath: "/", description: "Notify me of temperature", status: "active", entities: [ { id: "", isPattern: "", type: "https://uri.fiware.org/ns/data-models#WeatherObserved", isTypePattern: false } ], attrs: [ "https://uri.fiware.org/ns/data-models#temperature" ], metadata: [], blacklist: false, ldContext: "http://172.18.1.2/datamodels.context-ngsi.jsonld", createdAt: 1656060138.058298, modifiedAt: 1656060138.058298, conditions: [ "https://uri.fiware.org/ns/data-models#temperature" ], expression: { q: "https://uri=fiware=org/ns/data-models#temperature<100", mq: "", geometry: "", coords: "", georel: "", geoproperty: "" }, format: "normalized" }> from caller setCsf:302)
...

在此之前,我使用创建并验证了创建的订阅

创建:http://localhost:1026/ngsi-ld/v1/subscriptions/

{
  "description": "Notify me of temperature",
  "type": "Subscription",
  "entities": [{"type": "WeatherObserved"}],
  "watchedAttributes": ["temperature"],
  "notification": {
    "attributes": ["temperature"],
    "format": "normalized",
    "endpoint": {
      "uri": "http://172.18.1.5:8668/v2/notify",
      "accept": "application/json"
    }
  },
   "@context": "http://172.18.1.2/datamodels.context-ngsi.jsonld"
}

验证:http://localhost:1026/ngsi-ld/v1/subscriptions/

[
    {
        "id": "urn:ngsi-ld:Subscription:62b578ea4567412cdf07306e",
        "type": "Subscription",
        "description": "Notify me of temperature",
        "entities": [
            {
                "type": "WeatherObserved"
            }
        ],
        "watchedAttributes": [
            "temperature"
        ],
        "q": "https://uri.fiware.org/ns/data-models#temperature<100",
        "notification": {
            "attributes": [
                "temperature"
            ],
            "format": "normalized",
            "endpoint": {
                "uri": "http://172.18.1.5:8668/v2/notify",
                "accept": "application/json"
            }
        },
        "@context": "http://172.18.1.2/datamodels.context-ngsi.jsonld"
    },
    ...

因此,订阅似乎确实存在,并且 Orion 上下文代理尝试根据 Orion-LD 日志中重复的 MongoDB 错误( docker logs -f <orion ld container> )主动访问它。

这可能与旧的 MongoDB 驱动程序有关吗? 我发现了类似的问题https://github.com/telefonicaid/fiware-orion/issues/3070

这是我实际的 docker-compose 文件:

version: "3.8"
services:

  ########
  # CORE #
  ########
  # -> Orion: context broker as central component
  orion:
    labels:
      org.test: 'fiware'
    image: fiware/orion-ld:${ORION_VERSION}
    hostname: orion
    container_name: fiware-orion
    depends_on:
      - mongo-db
    networks:
      default:
        ipv4_address: 172.18.1.3
    ports:
      - "${ORION_PORT}:${ORION_PORT}"
    command: -dbhost mongo-db -logLevel DEBUG -noCache
    healthcheck:
      test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1
      interval: 5s

  # -> Context: provide ngsi-ld context file for smart data models 
  ld-context:
    labels:
      org.test: 'fiware'
    image: httpd:alpine
    hostname: context
    container_name: fiware-ld-context
    ports:
        - "3004:80"
    networks:
      default:
        ipv4_address: 172.18.1.2
    volumes:
        - ./context:/usr/local/apache2/htdocs/
    healthcheck:
      test: (wget --server-response --spider --quiet  http://172.18.1.2/datamodels.context-ngsi.jsonld 2>&1 | awk 'NR==1{print $$2}'|  grep -q -e "200") || exit 1
  
  
  ##################
  # DATA MANGEMENT #
  ##################
  # Quantum Leap: is persisting Short Term History to Crate-DB
  quantumleap:
    labels:
      org.test: 'fiware'
    image: orchestracities/quantumleap:${QUANTUMLEAP_VERSION}
    hostname: quantumleap
    container_name: fiware-quantumleap
    depends_on:
      - crate-db
      - redis-db
    networks:
      default:
        ipv4_address: 172.18.1.5
    ports:
      - "${QUANTUMLEAP_PORT}:${QUANTUMLEAP_PORT}"
    environment:
      - CRATE_HOST=crate-db
      - REDIS_HOST=redis-db
      - REDIS_PORT=${REDIS_PORT}
      - LOGLEVEL=DEBUG
    healthcheck:
      test: curl --fail -s http://quantumleap:${QUANTUMLEAP_PORT}/version || exit 1

  #################
  # VISUALIZATION #
  #################
  # -> Grafana: Visualize Time Series data
  grafana:
    labels:
      org.test: 'fiware'
    image: grafana/grafana:6.1.6
    container_name: grafana
    depends_on:
      - crate-db
    networks:
      default:
        ipv4_address: 172.18.1.8
    ports:
      - "3003:3000"
    environment:
      - GF_INSTALL_PLUGINS=https://github.com/orchestracities/grafana-map-plugin/archive/master.zip;grafana-map-plugin,grafana-clock-panel,grafana-worldmap-panel
    volumes:
      - grafana:/var/lib/grafana
  
  #############
  # DATABASES #
  #############
  # -> MongoDB: database of Orion
  mongo-db:
    labels:
      org.test: 'fiware'
    image: mongo:${MONGO_DB_VERSION}
    hostname: mongo-db
    container_name: db-mongo
    expose:
      - "${MONGO_DB_PORT}"
    ports:
      - "${MONGO_DB_PORT}:${MONGO_DB_PORT}" # localhost:27017 # localhost:27017
    networks:
      default:
        ipv4_address: 172.18.1.4
    volumes:
      - mongo-db:/data
    healthcheck:
      test: |
        host=`hostname --ip-address || echo '127.0.0.1'`; 
        mongo --quiet $host/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' && echo 0 || echo 1
      interval: 5s

  # -> CreateDB: database to store time-series data
  crate-db:
    labels:
      org.test: 'fiware'
    image: crate:${CRATE_VERSION}
    hostname: crate-db
    container_name: db-crate
    networks:
      default:
        ipv4_address: 172.18.1.6
    ports:
      # Admin UI
      - "4200:4200"
      # Transport protocol
      - "4300:4300"
    command: crate -Cauth.host_based.enabled=false  -Ccluster.name=democluster -Chttp.cors.enabled=true -Chttp.cors.allow-origin="*"
    environment:
      - CRATE_HEAP_SIZE=2g # see https://crate.io/docs/crate/howtos/en/latest/deployment/containers/docker.html#troubleshooting
    volumes:
      - crate-db:/data

  # -> Redis: Normally used to efficiently store key value pairs
  redis-db:
    labels:
      org.test: 'fiware'
    image: redis:${REDIS_VERSION}
    hostname: redis-db
    container_name: db-redis
    networks:
      default:
        ipv4_address: 172.18.1.7
    ports:
      - "${REDIS_PORT}:${REDIS_PORT}" # localhost:6379
    volumes:
      - redis-db:/data
    healthcheck:
      test: |
        host=`hostname -i || echo '127.0.0.1'`;
        ping=`redis-cli -h "$host" ping` && [ "$ping" = 'PONG' ] && echo 0 || echo 1
      interval: 10s


# NETWORKS
networks:
  default:
    labels:
      org.test: 'fiware'
    ipam:
      config:
        - subnet: 172.18.1.0/24

# VOLUMES
volumes:
  mongo-db: ~
  context: ~
  grafana: ~
  crate-db: ~
  redis-db: ~  

还有我相关的 .env 文件:

# Project name
COMPOSE_PROJECT_NAME=fiware

# Orion variables
ORION_PORT=1026
ORION_VERSION=1.0.0

# MongoDB variables
MONGO_DB_PORT=27017
MONGO_DB_VERSION=4.4

# QuantumLeap Variables
QUANTUMLEAP_VERSION=0.8.3
QUANTUMLEAP_PORT=8668

# CrateDB Version
CRATE_VERSION=4.6

# RedisDB Version
REDIS_PORT=6379
REDIS_VERSION=6

非常感谢您提供进一步的帮助,因为这个问题已经让我困扰了几天。 先感谢您!

你会这么好心并在 Orion-LD 的 github 上创建一个问题吗? 这似乎是一个错误报告,并不真正适合 SOF——我们用它来提问。 错误将作为问题报告: https ://github.com/FIWARE/context.Orion-LD/issues。 创建这个问题,我保证会尽快调查这个问题。

暂无
暂无

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

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