简体   繁体   中英

How to develop a new IoTAgent

I'm developing a new IoT Agent according to https://iotagent-node-lib.readthedocs.io/en/latest/howto/index.html

and I'm trying to run the following code: node index.js

but a warning shows up: (node:6176) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead. DEP0097 - Deprecation Warning (NODE.JS)

Any suggestions how to solve it? thank you!

It appears that you are running your IoT Agent under Node 14 . The Domain API has been deprecated and this is the cause of your warning. There is code within the IoT Agent Node lib currently uses the Domain API for communications with Telefonica Steelskin.

The IoT Agents are tested against LTS node releases, (currently 10 and 12 see here ) and Node 14 doesn't hit LTS until October 2020, so I would expect an interim release should fix the issue.

In the meantime if you run your agent under an earlier version of Node - for example via Docker. An example can be found in the Custom IoT Agent tutorial Dockerfile

ARG  NODE_VERSION=10.17.0-slim
FROM node:${NODE_VERSION}


COPY . /opt/iotXML/

WORKDIR /opt/iotXML

RUN \
    apt-get update && \
    apt-get install -y git && \
    npm install pm2@3.2.2 -g && \
    echo "INFO: npm install --production..." && \
    npm install --production && \
    # Remove Git and clean apt cache
    apt-get clean && \
    apt-get remove -y git && \
    apt-get -y autoremove && \
    chmod +x docker/entrypoint.sh

USER node
ENV NODE_ENV=production

# Expose 4041 for NORTH PORT, 7896 for HTTP PORT
EXPOSE ${IOTA_NORTH_PORT:-4041} ${IOTA_HTTP_PORT:-7896}

ENTRYPOINT ["docker/entrypoint.sh"]
CMD ["-- ", "config.js"]

The node version can be altered by adding NODE_VERSION to the Docker build command when building the Docker container.

The problem has to do with docker for windows toolbox. I installed linux and the custom iot agent worked. I think the problem ocurred because of the environment variables. For some reason windows 10 doesn't initiate.env archive variables that exist in the project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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