Description
Elixir wrapper for the emqttc library.
emqttc must currently be installed manually as it is not available on hex (yet).
Exmqttc alternatives and similar packages
Based on the "Third Party APIs" category.
Alternatively, view Exmqttc alternatives based on common mentions on social networks and blogs.
-
ethereumex
Elixir JSON-RPC client for the Ethereum blockchain 0x063D3d782598744AF1252eBEaf3aA97D990Edf72 -
MongoosePush
MongoosePush is a simple Elixir RESTful service allowing to send push notification via FCM and/or APNS. -
cashier
Cashier is an Elixir library that aims to be an easy to use payment gateway, whilst offering the fault tolerance and scalability benefits of being built on top of Erlang/OTP
CodeRabbit: AI Code Reviews for Developers

Do you think we are missing an alternative of Exmqttc or a related project?
README
Exmqttc

Elixir wrapper for the emqttc library.
emqttc must currently be installed manually as it is not available on hex (yet).
Installation
The package can be installed by adding exmqttc
and emqttc
to your list of dependencies in mix.exs
:
def deps do
[{:exmqttc, "~> 0.5"}, {:emqttc, github: "emqtt/emqttc"}]
end
Usage
Create a callback module:
defmodule MyClient do
require Logger
use Exmqttc.Callback
def init(_params) do
{:ok, []}
end
def handle_connect(state) do
Logger.debug "Connected"
{:ok, state}
end
def handle_disconnect(state) do
Logger.debug "Disconnected"
{:ok, state}
end
def handle_publish(topic, payload, state) do
Logger.debug "Message received on topic #{topic} with payload #{payload}"
{:ok, state}
end
end
You can keep your own state and return it just like with :gen_server
.
Start the MQTT connection process by calling start_link/3
:
{:ok, pid} = Exmqttc.start_link(MyClient, [], [host: '127.0.0.1'], params)
The third argument is a list of emqtt connection options, supporting the following options
host
: Connection host, charlist, default:'localhost'
port
: Connection port, integer, default 1883client_id
: Binary ID for client, automatically set to UUID if not specifiedclean_sess
: MQTT cleanSession flag.true
disables persistent sessions on the serverkeepalive
: Keepalive timer, integerusername
: Login username, binarypassword
: Login password, binarywill
: Last will, keywordlist, sample:[qos: 1, retain: false, topic: "WillTopic", payload: "I died"]
connack_timeout
: Timeout for connack package, integer, default 60puback_timeout
: Timeout for puback package, integer, default 8suback_timeout
: Timeout for suback package, integer, default 4ssl
: List of ssl optionsauto_resub
: Automatically resubscribe to topics, boolean, default:false
reconnect
: Automatically reconnect on lost connection, integer (), defaultfalse
Params are passed to the init function of your callback module.
You can publish messages to the given PID:
Exmqttc.publish(pid, "test", "foo")
publish/4
also supports passing in QOS and retain options:
Exmqttc.publish(pid, "test", "foo", qos: 2, retain: true)
Further docs can be found at https://hexdocs.pm/exmqttc.