Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Node.js Behavior in Heroku
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Inference API
      • Quick Start Guides
      • AI Models
      • Inference Essentials
    • Vector Database
    • Model Context Protocol
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Add-ons
  • All Add-ons
  • Stackhero for MQTT Mosquitto
Stackhero for MQTT Mosquitto

This add-on is operated by Stackhero

Mosquitto on dedicated instances, up-to-date versions and attractive prices.

Stackhero for MQTT Mosquitto

Last updated September 16, 2024

Table of Contents

  • Provisioning the Add-on
  • Local Setup
  • Connect to Stackhero Dashboard
  • Authentication
  • Connecting to MQTT Mosquitto
  • Upgrading Your Plan
  • Removing the Add-on
  • Support
  • Additional Resources

Stackhero for MQTT Mosquitto provides a managed MQTT Mosquitto instance running on a fully dedicated instance to handle thousands devices easily.

The Stackhero for MQTT Mosquitto add-on provides the folowing:

  • A private instance (dedicated VM) for high performances and security
  • TLS encryption (aka SSL)
  • Devices authentication and advanced ACLs via external API
  • An automatic backup every 24 hours
  • One click to update to new MQTT Mosquitto versions

There is an MQTT client library available for most languages including Ruby, Node.js, Java, Python, Clojure, and Erlang.

Provisioning the Add-on

You can attach Stackhero for MQTT Mosquitto via the CLI:

A list of all plans available can be found here.

$ heroku addons:create ah-mosquitto-mqtt-stackhero --app <your app name>
-----> Adding ah-mosquitto-mqtt-stackhero to sharp-mountain-4005... done

After you provision Stackhero for MQTT Mosquitto, the STACKHERO_MOSQUITTO_HOST and STACKHERO_MOSQUITTO_URL_TLS config variables are available in your app’s configuration. They contain the URLs to connect to your MQTT Mosquitto instance.

If you’ve checked the Allow clear connections option in your Mosquitto service, the STACKHERO_MOSQUITTO_URL_CLEAR environment variable will also be available. We don’t recommend using clear connections.

You can see the content of those variables via the heroku config:get command:

$ heroku config:get STACKHERO_MOSQUITTO_URL_TLS
$ heroku config:get STACKHERO_MOSQUITTO_LOGIN
$ heroku config:get STACKHERO_MOSQUITTO_PASSWORD

Local Setup

After you provision the add-on, you must replicate its config variables locally.

Use the Heroku Local command-line tool to configure, run, and manage process types specified in your app’s Procfile. Heroku Local reads configuration variables from an .env file. Use heroku config to view your app’s config variables. Use the following command for each value that you want to add to your .env file:

heroku config:get <STACKHERO_MOSQUITTO_VARIABLE> -s  >> .env

For example:

$ heroku config:get STACKHERO_MOSQUITTO_URL_TLS -s  >> .env
$ heroku config:get STACKHERO_MOSQUITTO_LOGIN -s  >> .env
$ heroku config:get STACKHERO_MOSQUITTO_PASSWORD -s  >> .env

Don’t commit credentials and other sensitive configuration values to source-control. In Git, exclude the .env file with: echo .env >> .gitignore.

For more information, see Heroku Local.

Connect to Stackhero Dashboard

You can see your instance usage, restart your instance, and apply updates from the Stackhero dashboard. You can access the dashboard via the CLI:

$ heroku addons:open ah-mosquitto-mqtt-stackhero
Opening ah-mosquitto-mqtt-stackhero for sharp-mountain-4005

You can also visit the Heroku Dashboard, select your application, and then select Stackhero for MQTT Mosquitto from the Add-ons menu.

Authentication

You can authenticate your users and devices connections to Mosquitto manually or with an external API.

Authenticating Manually

Manual authentication is useful when you are testing. If you want to handle more than 10 devices, you should authenticate with an external API.

You can use the manual authentication system to let your backend connect to Mosquitto and use the external API method to let your devices authenticate.

To add a new user, connect to your Stackhero dashboard, then select your Mosquitto service and choose “Configure”. For “Users”, specify a “login” and “password”. You can add up to 20 users with this method.

Authenticating using an External API

Use the external API to authenticate many devices. It can handle thousands of devices.

When a device connects to MQTT, Mosquitto makes an HTTP POST request to your API, passing a JSON string containing the username and the password for the device. If your API replies with an HTTP status code 200, the device is authorized. If it replies with a 401 (unauthorized) or another code, the device authentication is rejected.

For ACLs, 4 parameters are be passed: username, clientId, topic, acc. Your API must confirm username is allowed to make an acc type request on topic. acc can have the following values:

  • 1 - read access
  • 2 - write access
  • 3 - read and write access
  • 4 - subscribe access

For example, if the user userA tries to subscribe to the topic sensors/temperatures, your API receives the following JSON data:

{
  "username": "userA",
  "clientId": "userA",
  "topic": "sensors/temperatures",
  "acc": 4
}

See Gettng Started with Mosquitto to see an example API authentication server written in Jode.js.

Connecting to MQTT Mosquitto

You can retrieve your MQTT Mosquitto URL, username, and password via the following environment variables:

  • STACKHERO_MOSQUITTO_URL_TLS
  • STACKHERO_MOSQUITTO_LOGIN
  • STACKHERO_MOSQUITTO_PASSWORD

Upgrading Your Plan

You can’t downgrade an existing add-on.

Use the heroku addons:upgrade command to migrate to a new plan.

$ heroku addons:upgrade ah-mosquitto-mqtt-stackhero:newplan
-----> Upgrading ah-mosquitto-mqtt-stackhero:newplan to sharp-mountain-4005... done
       Your plan has been updated to: ah-mosquitto-mqtt-stackhero:newplan

Manage migration timing to ensure your application is available during the migration process.

Removing the Add-on

You can remove Stackhero for MQTT Mosquitto via the CLI:

This destroys all associated data and can’t be undone!

$ heroku addons:destroy ah-mosquitto-mqtt-stackhero
-----> Removing ah-mosquitto-mqtt-stackhero from sharp-mountain-4005... done

Support

Stackhero for MQTT Mosquitto support and runtime issues should be submitted via one of the Heroku Support channels. We recommend adding support@stackhero.io in copy for urgent issues.

Additional Resources

  • MQTT Mosquitto documentation by Stackhero
  • MQTT Mosquitto managed cloud

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Zara 4 Stackhero for MySQL

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices