Jasmine
Jasmine is a lightweight MQTT Broker for Android, developed using Kotlin and based on Netty.
Features
- Support for MQTT 3.1/3.1.1 protocol
- Full support for QoS 0, 1, 2 messages
- Support for Last Will and Testament messages, and retained messages
- Support for subscription topic wildcards
- Dual protocol support for WebSocket
- Default in-memory message persistence
- No support for anonymous access, but authentication is not required by default
- Support for custom authentication logic
- Support for SSL/TLS, one-way/two-way authentication
Integration
implementation("com.sunxiaodou.android:jasmine:[latest-version]")
Usage
Basic Usage
val jasmine = Jasmine.Builder().start() // Default port 1883
After successful startup, use any MQTT client to access <span>tcp://{IP}:1883</span> to connect to the Broker.
Advanced Usage
val jasmine = Jasmine.Builder()
.port(1883) // Specify port, default 1883
.enableSSL(true) // Enable SSL/TLS
.sslPort(1884) // Specify SSL/TLS port, default 1884
.serverCertFile(File("")) // Specify server certificate, must be specified when enabling SSL/TLS
.privateKeyFile(File("")) // Specify server private key, PKCS#8 format, must be specified when enabling SSL/TLS
.enableTwoWayAuth(true) // Enable two-way authentication
.caCertFile(File("")) // Specify CA certificate for client certificate, must be specified when enabling two-way authentication
.enableWebsocket(true) // Enable WebSocket
.websocketPort(8083) // Specify WebSocket port, default 8083
.websocketSSLPort(8084) // Specify WebSocket SSL/TLS port, default 8084
.websocketPath("/mqtt") // Specify WebSocket path, default /mqtt
.keepAliveInSeconds(5) // Specify client keep-alive duration, in seconds, default 5s, disconnect if no interaction with Broker
.retryInterval(3_000) // Specify QoS1/QoS2 message resend interval, in milliseconds, default 3_000 milliseconds
.maxRetries(5) // Specify maximum resend attempts for QoS1/QoS2 messages, default 5 times
.maxContentLength(65536) // Specify maximum content length for a single message, default 65536 bytes
.maxClientIdLength(255) // Specify maximum length for client ClientId, default 255
.jasmineCallback(this) // Inject Jasmine callback
.clientListener(this) // Inject client listener
.addAuthenticator(this) // Add custom authenticator
.start()
Future Features
- Data forwarding

Reference Articles
- Setting up an MQTT Broker on Android