eclipse-basyx / basyx-java-server-sdk

MIT License
55 stars 45 forks source link

Unable to retrieve list of AAS Identifiers from MongoDB in Discovery #301

Closed JBlezi closed 3 months ago

JBlezi commented 4 months ago

Description: I am experiencing an issue with the discovery service, where the AAS Ids linked to specific Asset Identifiers are successfully stored in the MongoDB (checked with mongosh), but cannot be retrieved using the /lookup/shells endpoint. The result is always empty:

{
"paging_metadata": {},
"result": []
}

This issue is only apparent when using MongoDB, it works correctly when using InMemory. Also noteworthy is the fact that when using the /lookup/shells{aasIdentifier} endpoint it works correctly as well, both with InMemory and with MongoDB.

Steps to reproduce:

  1. Start all the containers
  2. Upload a discovery entry in the form of a name/value pair via POST request with Postman:
[
    {
    "name": "DummyAssetName1",
    "value": "DummyAsset_1_Value"
    }
]
  1. Try accessing the discovery entry via /lookup/shells endpoint.

Configuration Files: 1. docker-compose.yaml:

version: "3.7"

services:

  mongodb:
    image: mongo:5.0.10
    volumes:
    - mongodb-data-version-5.0.10:/data/db
    container_name: mongodb-aasreg-smreg-v3
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: admin
    ports:
      - 27017:27017

  aas-registry-log-mongodb:
    image: eclipsebasyx/aas-registry-log-mongodb:latest
    container_name:  aas-registry-log-mongodb-v3
    environment:
      SPRING_DATA_MONGODB_URI: mongodb://admin:admin@mongodb:27017
    ports:
      - 8050:8080
    depends_on:
      - mongodb
    restart: always

  submodel-registry-log-mongodb:
    image: eclipsebasyx/submodel-registry-log-mongodb:2.0.0-SNAPSHOT
    container_name:  submodel-registry-log-mongodb-v3
    # pull_policy: never
    environment:
      SPRING_DATA_MONGODB_URI: mongodb://admin:admin@mongodb:27017
    ports:
      - 8051:8080
    depends_on:
      - mongodb
    restart: always

  aas-environment-log-mongodb:
    image: eclipsebasyx/aas-environment:2.0.0-SNAPSHOT
    volumes:
    - ./application.properties:/application/application.properties
    container_name:  aas-environment-v3
    # pull_policy: never
    ports:
      - 8082:8081
    depends_on:
      - mongodb
    restart: always

  mongo-express:
    image: mongo-express:1.0.0-alpha.4
    container_name: mongo-express-v3
    environment:
      ME_CONFIG_MONGODB_SERVER: mongodb
      ME_CONFIG_MONGODB_ADMINUSERNAME: admin
      ME_CONFIG_MONGODB_ADMINPASSWORD: admin
      ME_CONFIG_MONGODB_URL: mongodb://admin:admin@mongodb:27017/
    ports:
      - "0.0.0.0:8081:8081"
    depends_on:
      - mongodb

  aas-discovery-service:
    image: eclipsebasyx/aas-discovery:2.0.0-SNAPSHOT
    container_name: aas-discovery-service
    volumes:
      - ./application.properties:/application/application.properties
    ports:
      - 8083:8081
    depends_on:
      - mongodb
      - aas-environment-log-mongodb
      - aas-registry-log-mongodb
      - submodel-registry-log-mongodb

volumes:
   mongodb-data-version-5.0.10:
      driver: local

2. application.properties

server.port=8081
spring.application.name=AAS Environment

# basyx.backend = InMemory

basyx.backend = MongoDB
spring.data.mongodb.host=mongodb
spring.data.mongodb.port=27017
spring.data.mongodb.database=aasenvironments
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=admin
spring.data.mongodb.password=admin

I have been trying around many different configurations, but nothing seemed to have any effect. Please let me know if my configuration is correct or if I need any additional configurations to resolve this problem?

Many thanks in advance!

mdanish98 commented 4 months ago

Hi @JBlezi ,

Thanks for raising this issue. We are analyzing this issue and will get back to you with the analysis/fix.

aaronzi commented 3 months ago

Hi @JBlezi,

I tried to reproduce your issue but for me everything was working just fine. Here is the setup I used: MongoDiscoveryIssue.zip

I executed the following three requests via Postman to verify that it's working:

  1. Create a new link:
    curl --location 'http://localhost:8084/lookup/shells/aHR0cHM6Ly9leGFtcGxlLmNvbS9pZHMvYWFzLzEyNzNfOTA5MF80MDQyXzQ5MTg' \
    --header 'Content-Type: application/json' \
    --data '[
    {
        "name": "globalAssetId",
        "value": "https://example.com/ids/asset/1373_9090_4042_5900"
    }
    ]'
  2. Get the created link by aasIdentifier:
    curl --location 'http://localhost:8084/lookup/shells/aHR0cHM6Ly9leGFtcGxlLmNvbS9pZHMvYWFzLzEyNzNfOTA5MF80MDQyXzQ5MTg'
  3. Get the link by assetId:
    curl --location 'http://localhost:8084/lookup/shells?assetIds=eyJuYW1lIjoiZ2xvYmFsQXNzZXRJZCIsInZhbHVlIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9pZHMvYXNzZXQvMTM3M185MDkwXzQwNDJfNTkwMCJ9'

Every request returned the expected results. Since I don't know what exact request you send via Postman or what your exact BaSyx configuration looks like I would assume it's either a small mistake in the request you are sending or a configuration issue in BaSyx.

Hope this helps

JBlezi commented 3 months ago

Hi @aaronzi, thank you for your response. This is working for me as well now. I was using an older version of the endpoint (V3.0.1_SSP001). It works now that I am using V3.0.1_SSP002. Thank you!