Skip to main content

Overview

The Coreflux MQTT Broker can be configured at startup through command-line arguments, making it ideal for automated deployments, containerized environments, and system service installations. Instead of manually configuring the broker after startup, you can pass configuration files directly—perfect for CI/CD pipelines, Docker, Kubernetes, and production provisioning.
Think of startup options as a recipe card for your broker. You tell it exactly how to configure itself before it starts—which users to create, which routes to load, which actions to deploy. The broker reads the recipe and sets itself up automatically.

In This Page

SectionDescription
Command-Line OptionsAll available startup flags
Configuration FilesBroker, users, and LoT file formats
Docker DeploymentContainer and Kubernetes deployment
Service InstallationWindows, Linux, and Raspberry Pi

Command-Line Options

Configuration Management

OptionLong FormDescription
-c--configPath to broker configuration JSON file
-cf--config-forceForce overwrite existing broker configuration
-u--usersPath to users configuration JSON file
-uf--users-forceForce overwrite existing users configuration
-p--pathCustom base path for Coreflux data directory

LoT Entity Loading

OptionLong FormDescription
-lotrt--lot-routesPath to Routes definition file
-lota--lot-actionsPath to Actions definition file
-lotm--lot-modelsPath to Models definition file
-lotrl--lot-rulesPath to Rules definition file

Other Options

OptionLong FormDescription
-I--installInstall as a system service
-h--helpDisplay help information

Environment Variables

VariableDescriptionDefault
CONFIG_PATHBase directory for Coreflux configuration filesApplication directory

Basic Usage

Starting with Configuration Files

# Start with broker configuration
./CorefluxMQTTBroker --config /path/to/broker-config.json

# Start with users configuration
./CorefluxMQTTBroker --users /path/to/users.json

# Start with both
./CorefluxMQTTBroker \
    --config /path/to/broker-config.json \
    --users /path/to/users.json

Force Overwrite Existing Configuration

By default, if configuration files already exist, startup arguments are ignored. Use force flags to overwrite:
# Force overwrite broker config
./CorefluxMQTTBroker --config /path/to/broker-config.json --config-force

# Force overwrite users config  
./CorefluxMQTTBroker --users /path/to/users.json --users-force

# Force overwrite both (short form)
./CorefluxMQTTBroker -c /path/to/broker-config.json -cf -u /path/to/users.json -uf
Force flags overwrite existing configurations. Back up your current configuration before using them.

Loading LoT Entities at Startup

Pre-load Actions, Models, Routes, and Rules when the broker starts:
# Load all LoT entities
./CorefluxMQTTBroker \
    --config /path/to/broker-config.json \
    --users /path/to/users.json \
    --lot-routes /path/to/routes.lot \
    --lot-actions /path/to/actions.lot \
    --lot-models /path/to/models.lot \
    --lot-rules /path/to/rules.lot
This is ideal for deploying complete IoT solutions. Package your broker, users, and all LoT logic into a single startup command.

Configuration Files

Broker Configuration (JSON)

The broker configuration file defines MQTT service settings:
{
  "Name": "MyCorefluxBroker",
  "Port": 1883,
  "TlsPort": 8883,
  "WebsocketPort": 5000,
  "WebsocketPortTls": 443,
  "BindIPForMQTT": "0.0.0.0",
  "BindIPForMQTTwithTls": "0.0.0.0",
  "BindIpForWebSockets": "0.0.0.0",
  "BindIpForWebSocketsTls": "0.0.0.0",
  "AnonymousLogin": false,
  "FullDebugLog": false,
  "ServerCertificatePath": "/path/to/certificate.pfx",
  "ServerCertificatePassword": "your-certificate-password",
  "ResendRetainTopics": false
}

Broker Configuration Properties

PropertyTypeDefaultDescription
Namestring-Name of the MQTT broker
Portint1883Default MQTT port
TlsPortint8883TLS-encrypted MQTT port
WebsocketPortint5000MQTT over WebSocket port
WebsocketPortTlsint443MQTT over WebSocket with TLS port
BindIPForMQTTstring0.0.0.0IP address to bind for MQTT
AnonymousLoginboolfalseAllow anonymous connections
FullDebugLogboolfalseEnable detailed debug logging

Users Configuration (JSON)

The users configuration file defines MQTT users and their permissions:
[
  {
    "UserName": "root",
    "Password": "your-secure-password",
    "AllowedBaseTopic": "#",
    "AllowedSystemConfiguration": true,
    "AllowedAssetManipulation": true,
    "AllowedUserManagement": true,
    "AllowedLogManagement": true
  },
  {
    "UserName": "device-user",
    "Password": "device-password",
    "AllowedBaseTopic": "devices/",
    "AllowedSystemConfiguration": false,
    "AllowedAssetManipulation": false,
    "AllowedUserManagement": false,
    "AllowedLogManagement": false
  }
]

User Permission Properties

PropertyTypeDescription
UserNamestringMQTT username
PasswordstringMQTT password
AllowedBaseTopicstringTopic access restriction (# for all topics)
AllowedSystemConfigurationboolAllow system configuration changes
AllowedAssetManipulationboolAllow LoT entity installation/removal
AllowedUserManagementboolAllow user management operations
AllowedLogManagementboolAllow log management operations

LoT Entity Files

Create .lot files with your entity definitions: actions.lot:
DEFINE ACTION Heartbeat
ON EVERY 10 SECONDS DO
    PUBLISH TOPIC "system/heartbeat" WITH TIMESTAMP "UTC"

DEFINE ACTION TemperatureProcessor
ON TOPIC "sensors/+/temperature" DO
    SET "sensor_id" WITH TOPIC POSITION 2
    PUBLISH TOPIC "processed/" + {sensor_id} WITH PAYLOAD
routes.lot:
DEFINE ROUTE DatabaseRoute WITH TYPE POSTGRESQL
    ADD POSTGRESQL_CONFIG
        WITH HOST "localhost"
        WITH PORT 5432
        WITH DATABASE "iot_data"
        WITH USERNAME "postgres"
        WITH PASSWORD "password"
    ADD MAPPING "StoreSensorData"
        WITH SOURCE_TOPIC "sensors/+/data"
        WITH QUERY "INSERT INTO readings (topic, value) VALUES ('{source_topic}', '{payload}')"

Container Deployment

Deploy the Coreflux broker using containers or orchestration platforms:
Run the broker with mounted configuration files:
docker run -d \
  --name coreflux-broker \
  -p 1883:1883 \
  -p 5000:5000 \
  -v /host/config:/config:ro \
  -v /host/data:/app/Coreflux \
  coreflux/broker:latest \
  --config /config/broker-config.json \
  --users /config/users.json \
  --lot-routes /config/routes.lot \
  --lot-actions /config/actions.lot \
  --config-force \
  --users-force
Key volume mounts:
  • /config — Read-only mount for configuration files
  • /app/Coreflux — Persistent storage for broker data

Service Installation

Install Coreflux as a system service for automatic startup:
1

Download the Broker

Download the Windows binary from coreflux.org/downloads.
2

Open Administrator Command Prompt

Right-click Command Prompt and select “Run as administrator”.
3

Install the Service

Navigate to the broker directory and run:
.\CorefluxMQTTBroker.exe --install
Response: Coreflux MQTT Broker service installed successfully
4

Start the Service

Start the service using Windows Services or:
net start CorefluxMQTTBroker
5

Verify Installation

Check the service is running:
Get-Service CorefluxMQTTBroker
Install with Pre-Configuration:To install with pre-configured settings, first run the broker once with your configuration:
# Configure the broker first
.\CorefluxMQTTBroker.exe `
    --config C:\Coreflux\config\broker-config.json `
    --users C:\Coreflux\config\users.json `
    --config-force --users-force

# Stop the broker (Ctrl+C), then install as service
.\CorefluxMQTTBroker.exe --install

File Storage Locations

When the broker runs, it stores data in these locations:
FilePathDescription
Broker Config{base}/Coreflux/bin/Anselmo.ralphEncrypted broker configuration
Users Config{base}/Coreflux/bin/ana.malhoaEncrypted users configuration
Routes{base}/Coreflux/bin/Roberto.LealRoutes definitions
Actions{base}/Coreflux/bin/Saul.RicardoActions definitions
Models{base}/Coreflux/bin/Marco.PauloModels definitions
Rules{base}/Coreflux/bin/Ze.CabraPermission rules
Python Scripts{base}/Coreflux/bin/Python.ScriptsPython script definitions
Logs{base}/Coreflux/log/Log files
Where {base} is determined by:
  1. The CONFIG_PATH environment variable, or
  2. The --path argument, or
  3. The application’s base directory

Best Practices

The -cf and -uf flags overwrite existing configurations. Only use them when you intentionally want to reset configurations. Back up existing configs first.
Users configuration contains passwords. Ensure proper file permissions:
chmod 600 /opt/coreflux/config/users.json
In production, consider using secrets management (Kubernetes Secrets, HashiCorp Vault).
Always mount a persistent volume for /app/Coreflux in Docker/Kubernetes. This preserves your broker state across container restarts.
Test your configuration files locally before deploying to production. Start the broker manually and verify it works correctly.

Troubleshooting

If your startup configuration is not being applied:
  1. Check if configuration files already exist in the data directory
  2. Use the force flags (-cf, -uf) to overwrite existing configuration
  3. Check logs for validation errors
If the broker fails to start due to port conflicts:
# Check what's using port 1883
sudo lsof -i :1883

# Or on Windows
netstat -ano | findstr :1883
Either stop the conflicting service or change the broker port in your configuration.
Ensure the service user has:
  • Read access to configuration files
  • Write access to the data directory
  • Proper permissions for TLS certificate files
sudo chown -R coreflux:coreflux /opt/coreflux

Next Steps