alex88

alex88

I’ve tried multiple mqtt clients and almost no one has ssl client support except exmqtt that wraps emqttc, using that I’ve tried to connect to aws iot using:

{:ok, pid} = Exmqttc.start_link(MqttClient, [], [
  host: 'xxxxxx.iot.eu-west-1.amazonaws.com',
  port: 8883,
  clean_sess: true,
  ssl: [
    certfile: Application.app_dir(:dem, "priv/mqtt-certificate.pem.crt"),
    keyfile: Application.app_dir(:dem, "priv/mqtt-private.pem.crt")
  ],
  auto_resub: true,
  reconnect: true
], %{})
Exmqttc.subscribe(pid, "#")

however none of the connect/disconnect callbacks are called. My callbacks module is:

defmodule MqttClient 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

does someone have any idea? Is my elixir config correct? (specially the ssl part which I’m not sure is the right elixir counterpart of the erlang code)

Showing Posts 1 to 6

gausby

gausby

I haven’t tried connecting to a amazon hosted MQTT server, but I do have a client called Tortoise, and it does support SSL. Currently it lacks documentation, and I am about to write some; have you tried it? What’s your experience? Where should I focus in the documentation?

I was thinking I should make a “guides” section in the documentation where topics such as connecting to AWS hosted MQTT could be described.

alex88

alex88 OP

Thanks for the reply, I went through tortoise but without any doc and since I was in a hurry I’ve just used gen_mqtt (which is also yours :slight_smile:) with mosquitto which bridges the client to AWS IOT.

Btw regarding documentation a non-ssl/ssl and an handler example (just saw that in the tests) would be more than enough!

gausby

gausby

Awesome. Perhaps I should write a macro that will make implementing a Tortoise.Handler easier with default implementations for most of the callbacks. Currently I am making an attempt to improve the documentation for Tortoise over at this pull request:

Don’t be shy if you have any feedback.

Hris

Hris

I red the documentation but I didn’t manage to do the SSL connection with Tortoise. Could you please explain about the options? cacertfile, key, cert. Is it a path? Is it a string of what file contains? what is it ? I couldn’t find documentation for this.

miked

miked

@gausby could you tell me if the Tortoise client supports MQTT v5.0? I know GitHub - jacky-xbb/exmqtt: Elixir MQTT v5.0 Client · GitHub is an Elixir MQTT v5.0 Client compatible with MQTT v3.0.

gausby

gausby

Not yet; but hopefully I can get to work on Tortoise at some point in the near future. Sorry I have been away for a long while. Feel free to check out other options. The MQTT 5 version of Tortoise will have a different interface than the one that worked for MQTT 3.1.1, so if you have something working already a slight rewrite of your MQTT parts will be required anyways.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews