[Backlogmanager] [FIWARE-JIRA] (HELP-22018) [fiware-stackoverflow] Fiware IoT Agent JSON connection to MongoDB with authentication

Fernando Lopez (JIRA) jira-help-desk at jira.fiware.org
Tue Aug 15 14:18:00 CEST 2023


     [ https://jira.fiware.org/browse/HELP-22018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fernando Lopez reassigned HELP-22018:
-------------------------------------

    Assignee: Miguel Ángel Pedraza

> [fiware-stackoverflow] Fiware IoT Agent JSON connection to MongoDB with authentication
> --------------------------------------------------------------------------------------
>
>                 Key: HELP-22018
>                 URL: https://jira.fiware.org/browse/HELP-22018
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Miguel Ángel Pedraza
>              Labels: fiware
>
> Created question in FIWARE Q/A platform on 14-08-2023 at 21:08
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/76902281/fiware-iot-agent-json-connection-to-mongodb-with-authentication
> +Question:+
> Fiware IoT Agent JSON connection to MongoDB with authentication
> +Description:+
> I'm trying to configure the Fiware IOT Agent Json connection to MongoDB with authentication, but I always get the Authentication Failed error.
> I'm running the services via docker-compose, and in the Fiware IOT Agent JSON I have the environment variables IOTA_MONGO_USER and IOTA_MONGO_PASSWORD defined, which correspond to the mongodb username and password.
> Here I put some parts of my docker-compose:
>  iot-agent:
>     image: fiware/iotagent-json:latest
>     hostname: iot-agent
>     container_name: fiware-iot-agent
>     depends_on:
>         - mongo-db
>     networks:
>         - fiware
>     ports:
>         - "4041:4041" 
>         - "7896:7896"
>     environment:
>         - IOTA_MONGO_HOST=mongo-db
>         - IOTA_MONGO_PORT=${MONGO_DB_PORT}
>         - IOTA_MONGO_USER=${MONGO_USER}
>         - IOTA_MONGO_PASSWORD=${MONGO_PWD}
>         - IOTA_MONGO_DB=iotagentul
>  mongo-db:
>     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
>     networks:
>         - fiware
>     volumes:
>         -  ./volumes/mongo-db/db:/data/db
>     environment:
>         - MONGO_INITDB_ROOT_USERNAME=${MONGO_USER}
>         - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PWD}
> The error log is this:
> (Note: the user and password in the fields below appears fine, I removed it from the post for security)
> subsrv=n/a | msg=Attempting to connect to MongoDB instance with url "mongodb://mongo-db:27017/iotagentul" and options {"auth":{"user":"","password":""}}. Attempt 1 | comp=IoTAgent
> (node:1) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
> (Use node --trace-warnings ... to show where the warning was created)
> (node:1) [MONGODB DRIVER] Warning: Warning: no saslprep library specified. Passwords will not be sanitized
> time=2023-08-14T21:12:11.543Z | lvl=ERROR | corr=9ad5f04f-8b95-4292-837e-54c57de0461d | trans=9ad5f04f-8b95-4292-837e-54c57de0461d | op=IoTAgentNGSI.DbConn | from=n/a | srv=n/a | subsrv=n/a | msg=MONGODB-001: Error trying to connect to MongoDB: MongoNetworkError: failed to connect to server [mongo-db:27017] on first connect [MongoError: Authentication failed.
> at Connection.messageHandler (/opt/iotagent-json/node_modules/mongodb/lib/core/connection/connection.js:364:19)
> at Connection.emit (node:events:513:28)
> at Connection.emit (node:domain:552:15)
> at processMessage (/opt/iotagent-json/node_modules/mongodb/lib/core/connection/connection.js:456:10)
> at Socket. (/opt/iotagent-json/node_modules/mongodb/lib/core/connection/connection.js:625:15)
> at Socket.emit (node:events:513:28)
> at Socket.emit (node:domain:552:15)
> at addChunk (node:internal/streams/readable:315:12)
> at readableAddChunk (node:internal/streams/readable:289:9)
> at Socket.Readable.push (node:internal/streams/readable:228:10)
> at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
> at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
> ok: 0,
> code: 18,
> codeName: 'AuthenticationFailed'
> }]
> Does anyone know what could be going wrong?
> Thanks



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy