All Projects → davidepianca98 → KMQTT

davidepianca98 / KMQTT

Licence: MIT license
Embeddable and standalone Kotlin Multiplatform MQTT broker

Programming Languages

kotlin
9241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to KMQTT

mqtt
Kotlin cross-platform, coroutine based, reflectionless MQTT 3.1.1 & 5.0 client & server
Stars: ✭ 31 (-44.64%)
Mutual labels:  mqtt-broker, mqtt-server, kotlin-native
mqtt
The fully compliant, embeddable high-performance Go MQTT v5 server for IoT, smarthome, and pubsub
Stars: ✭ 356 (+535.71%)
Mutual labels:  mqtt-broker, mqtt-server
KotlinXcodeSync
Sync Kotlin files with an Xcode project
Stars: ✭ 25 (-55.36%)
Mutual labels:  kotlin-native, kotlin-multiplatform
MultiplatformPlayground
Kotlin Multiplatform project in Jetpack Compose & SwiftUI with shared ViewModel layer and File upload
Stars: ✭ 72 (+28.57%)
Mutual labels:  kotlin-native, kotlin-multiplatform
StarWars
Minimal GraphQL based Jetpack Compose, Wear Compose and SwiftUI Kotlin Multiplatform sample (using StarWars endpoint - https://graphql.org/swapi-graphql)
Stars: ✭ 165 (+194.64%)
Mutual labels:  kotlin-native, kotlin-multiplatform
MQTTnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 3,309 (+5808.93%)
Mutual labels:  mqtt-broker, mqtt-server
nmqtt
Native Nim MQTT client library
Stars: ✭ 39 (-30.36%)
Mutual labels:  mqtt-broker, mqtt-server
cognito-idp
Lightweight AWS Cognito Identity Provider client for Kotlin Multiplatform and Typescript projects.
Stars: ✭ 14 (-75%)
Mutual labels:  kotlin-native, kotlin-multiplatform
jo-mqtt
java mqtt-server/broker 使用简单 扩展方便 集群稳定 轻松支持10万并发 已用于生产环境
Stars: ✭ 71 (+26.79%)
Mutual labels:  mqtt-broker, mqtt-server
KParser
Kotlin Multiplatform Arithmatic Parser
Stars: ✭ 32 (-42.86%)
Mutual labels:  kotlin-native, kotlin-multiplatform
kmm-production-sample
This is an open-source, mobile, cross-platform application built with Kotlin Multiplatform Mobile. It's a simple RSS reader, and you can download it from the App Store and Google Play. It's been designed to demonstrate how KMM can be used in real production projects.
Stars: ✭ 1,476 (+2535.71%)
Mutual labels:  kotlin-native, kotlin-multiplatform
Splitties
A collection of hand-crafted extensions for your Kotlin projects.
Stars: ✭ 1,945 (+3373.21%)
Mutual labels:  kotlin-native, kotlin-multiplatform
kinsight-multiplatform
Kotlin Multiplatform Concept - iOS, MacOS, WatchOS (SwiftUI), Android (phone and Wear OS), JVM Web Server - Alpha Capture
Stars: ✭ 38 (-32.14%)
Mutual labels:  kotlin-native, kotlin-multiplatform
Mqttnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 2,486 (+4339.29%)
Mutual labels:  mqtt-broker, mqtt-server
TMDbMultiplatform
Step-by-step guide on Kotlin Multiplatform
Stars: ✭ 86 (+53.57%)
Mutual labels:  kotlin-native, kotlin-multiplatform
hivemq4-docker-images
Official Docker Images for the Enterprise MQTT Broker HiveMQ
Stars: ✭ 18 (-67.86%)
Mutual labels:  mqtt-broker, mqtt-server
koru
Simple coroutine wrappers for Kotlin Native. Generated from annotations. Compatible with RxSwift, Combine etc.
Stars: ✭ 141 (+151.79%)
Mutual labels:  kotlin-native, kotlin-multiplatform
Arbor
Like Timber, just different
Stars: ✭ 55 (-1.79%)
Mutual labels:  kotlin-native, kotlin-multiplatform
moko-geo
Geolocation access for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 41 (-26.79%)
Mutual labels:  kotlin-native, kotlin-multiplatform
Emqx
An Open-Source, Cloud-Native, Distributed MQTT Message Broker for IoT.
Stars: ✭ 8,951 (+15883.93%)
Mutual labels:  mqtt-broker, mqtt-server

KMQTT

Release

KMQTT is a Kotlin Multiplatform MQTT 3.1.1/5.0 Broker, with the objective of targeting the most possible build targets.

Features

= To Do
= Supported
= Work In Progress

Platform MQTT 3.1.1 MQTT 5.0 TCP TLS Websocket Clustering
JVM
Windows X64
Windows X86
Linux X64
Linux ARM32
Linux ARM64
Node.js

Getting Started

Executables

You can download the executables for your platform under the release tab

Program Arguments

Argument Default Value Description
-h 127.0.0.1 Interface address to bind the server to
-p 1883 Server port to listen to
--max-connections 128 The maximum number of TCP connections to support
--key-store null The path to the PKCS12 keystore containing the private key and the certificate for TLS, if null TLS is disabled
--key-store-psw null The password of the PKCS12 keystore indicated in --key-store, if the keystore has no password set, don't set the option
--wsp null The WebSocket port to listen to

Library

Gradle Maven

Global dependencies
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}
dependencies {
    implementation 'com.github.davidepianca98.KMQTT:kmqtt-jvm:0.3.2'
}

Replace jvm with js, linuxx64, linuxarm64, linuxarm32hfp, mingwx64, mingwx86 based on the desired target.

Kotlin Multiplatform plugin

On the Kotlin Multiplatform plugin you only need to require the dependency on the common source set and the platform specific parts will automatically be required

repositories {
    jcenter()
    maven { url "https://jitpack.io" }
}

kotlin {
    jvm()
    mingwX64("mingw")
    sourceSets {
        commonMain {
            dependencies {
                implementation 'com.github.davidepianca98.KMQTT:kmqtt:0.3.2'
            }
        }
    }
}

Quick start code example

This code starts the MQTT broker on port 1883 without TLS encryption. You can play with Broker() constructor parameters to set the various settings

fun main() {
    Broker().listen()
}

TLS code example

The keystore must be in PKCS12 format, the keystore password can be null

fun main() {
    val broker = Broker(
        tlsSettings = TLSSettings(keyStoreFilePath = "keyStore.p12", keyStorePassword = "password"),
        port = 8883
    ).listen()
    broker.listen()
}

Authentication code example

fun main() {
    val broker = Broker(authentication = object : Authentication {
        override fun authenticate(clientId: String, username: String?, password: UByteArray?): Boolean {
            // TODO Implement your authentication method    
            return username == "user" && password?.toByteArray()?.decodeToString() == "pass"
        }
    })
    broker.listen()
}

Authorization code example

fun main() {
    val broker = Broker(authorization = object : Authorization {
        override fun authorize(
            clientId: String,
            username: String?,
            password: UByteArray?, // != null only if savePassword set to true in the broker constructor
            topicName: String,
            isSubscription: Boolean,
            payload: UByteArray?
        ): Boolean {
            // TODO Implement your authorization method    
            return topicName == "$clientId/topic"
        }
    })
    broker.listen()
}

Message interceptor code example

fun main() {
    val broker = Broker(packetInterceptor = object : PacketInterceptor {
        override fun packetReceived(clientId: String, username: String?, password: UByteArray?, packet: MQTTPacket) {
            when (packet) {
                is MQTTConnect -> println(packet.protocolName)
                is MQTTPublish -> println(packet.topicName)
            }
        }
    })
    broker.listen()
}

Internal publish code example

fun main() {
    val broker = Broker()
    broker.publish(
        retain = false,
        topicName = "test/",
        qos = Qos.AT_MOST_ONCE,
        properties = MQTTProperties(),
        "testPayload".toByteArray().toUByteArray()
    )
    broker.listen()
}

Other advanced functionality

MQTT5 Enhanced Authentication: set the enhancedAuthenticationProviders Broker constructor parameter, implementing the provider interface EnhancedAuthenticationProvider.

Session persistence: set the persistence Broker constructor parameter, implementing Persistence interface.

Bytes metrics: set the bytesMetrics Broker constructor parameter, implementing BytesMetrics interface.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].