Git Product home page Git Product logo

mqtt-osem-integration's Introduction

openSenseMap MQTT Integration

MQTT client service for openSenseMap API. Connects to remote MQTT brokers and stores incoming messages in the database of openSenseMap. Communication with the main openSenseMap API is done through gRPC calls. You can find the .proto file in the osem-protos repository.

Configuration

Configuration is handled by node-config.

See config/default.json. You should at least configure the connection to the database and the certificates for GRPC. Certificates can either configured directly as strings or can take a path to a file in pem format.

{
  "grpc": {
    "certificates": {
      // example for path
      "ca_cert": "/etc/ssl/certs/My_CA.pem",
      // example for stringified certificate (sed -z 's/\n/\\n/g' < certificate.crt)
      "server_cert": "-----BEGIN CERTIFICATE-----\nMIIE9DCCAtygAwIBA ... ",
      "server_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIJKQIBAAKCAg ..."
    }
  },
  "openSenseMap-API-models": {
    "db": {
      // See example config json of @sensebox/opensensemap-api-models
      "mongo_uri"
    }
  }
}

Development

To get up and running for development run the following steps:

  • Run npm install
  • Run ./scripts/setup_certs.sh for generating development certificates.
  • Set the MQTT URL in row 23 in ./seeds/devices.json
  • Run docker-compose up -d

Environment variables

Its possible to supply your configuration json through the NODE_CONFIG environment variable. It is also possible to configure through custom environment variables:

Config key Environment Variable Description
mqtt_client.num_retries OSEM_MQTT_NUM_RETRIES Number of retries which the MQTT client takes until backing off
mqtt_client.retry_after_minutes OSEM_MQTT_RETRY_AFTER_MINUTES Minutes after the MQTT clients restarts connecting after errors
grpc.port OSEM_MQTT_GRPC_PORT Port on which the gRPC server listens
grpc.certificates.ca_cert OSEM_MQTT_GRPC_CA_CERT CA certificate for gRPC TLS client authentication. Can be specified either as path to a certificate file or the certificate directly.
grpc.certificates.server_cert OSEM_MQTT_GRPC_SERVER_CERT Server certificate for gRPC TLS client authentication. Can be specified either as path to a certificate file or the certificate directly.
grpc.certificates.server_key OSEM_MQTT_GRPC_SERVER_KEY Server certificate key for gRPC TLS client authentication. Can be specified either as path to a key file or the key directly.

Container images and Versions

Container images for this service are created on each push on Github Container Registry.

Stable versions should be tagged using npm version and git push --follow-tags origin master

mqtt-osem-integration's People

Contributors

dependabot[bot] avatar mpfeil avatar ubergesundheit avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ubergesundheit

mqtt-osem-integration's Issues

Support mqtts

To support mqtts we need to upgrade the used mqttpackage.

Tried to connect with version 2.x to a mqtts endpoint offered by HiveMQ without success.
Also tried same connection url with version 4.x and it´s working.

Update grpc package

It´s also outdated for a long time. We have to update it and also the one in the API.

Connection to HiveMQ or DIoTY works for only a few minutes

Hi! I have tried to connect from the testing environment ( https://testing.opensensemap.org/ ) to HiveMQ over MQTTS and after a minute or two published messages aren't saved anymore or the client disconnects. I ran the project locally and the connection isn't closed, all the messages sent to the broker are received, even after 15+ minutes running. The same behavior happens when trying to connect over MQTT to https://dioty.co/ from the prod environment ( https://opensensemap.org/ ). Changing the topic or connection options and saving the config makes the connection work for the next 1-2 minutes. The integration with MyQttHub works perfectly in the prod env, the client doesn't disconnect. Is this a testing environment specific issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.