greenz1

greenz1

Hulaaki vs GenMQTT

I am setting up MQTT server with VerneMQ as a broker. I have to receive messages from a client and store them in a database (OrientDB) on the server. For server side, we largely rely on Elixir as our backend. So, now I have to select one of those but due to lack of resources, I cannot find anything which objectively compares these two libraries for connecting with MQTT brokers. Please find the links below.

Also, do these support interoperability with different MQTT brokers available?
How well do these handle multiple pubs and subs (connections) from and to various clients?
Hulaaki supports SSL/TLS but I couldnt’ find similar feature in GenMQTT?

Why are we using MQTT?
MQTT is being used to send push notifications from our server to mobile users, and receive messages from server to client and client to client.

GenMQTT and Hulaaki

Most Liked

gausby

gausby

I guess I deserve the questions when I haven’t written documentation yet :slight_smile:

You have to implement a callback module for handling the incoming traffic; you can see examples of these in the Tortoise.Handler.Logger, which implement the Tortoise.Handler-behaviour. The key is to do non-blocking calls here, as the process running the handler is the process that own the main controller—in other words, use it to pattern match on the incoming data and dispatch it to other processes!

When you have a connection you can use the client_id you used for the connection in the Tortoise.publish/4. If you publish with a QoS you will get a message in your process mailbox when the message has been handed over to the server—there is a Tortoise.publish_sync/4 variant that will block the calling process until it has been delivered (this of course only make sense for messages with a quality of service bigger than 0, as 0 is a fire and forget)

So: You have to implement a callback behaviour called Tortoise.Handler for receiving messages, which should do as little as possible; just dispatch messages to the rest of the system; and you should use the Tortoise.publish/publish_sync to publish to the broker; then Tortoise should handle the details of the protocol!

gausby

gausby

Hi, I am the author of Tortoise (as well as the gen_mqtt client/wrapper)

Tortoise is the successor to gen_mqtt; it doesn’t quite work the way I described in a previous post (I have a full time job and all that, so time is scarce which conflicts with really ambitious projects) but I think Tortoise is really nice at separating the MQTT semantics from the Elixir semantics; right now it support publishing and subscribing to topics with Quality of Service 0 through 2; TCP and SSL transports, and it behaves pretty well when it reconnect to the broker.

I still have some way to go before I can call it 1.0, but I’d say it is usable now; everyone who uses gen_mqtt should switch to Tortoise. Don’t be shy if you have any questions :slight_smile:

gausby

gausby

Hi. I did the GenMQTT project that wraps an Erlang module called gen_emqtt that was written by Erlio for their VerneMQ MQTT broker. gen_emqtt used to be in a separate project called vmq_commons, but that project has been moved into the vernemq application, and hence the gen_emqtt is no longer available without getting the entire VerneMQ broker.

GenMQTT is thus deprecated, because I am not going to maintain the Erlang library, since it has some flaws—a proper error kernel being one of them. I am working on an implementation in pure Elixir, and I have some different approaches than Hulaaki. I don’t know how long this will take as I have a fulltime job that doesn’t relate to MQTT.

As for now I would recommend looking into both Hulaaki and GenMQTT; if you decide to go with GenMQTT I will happily accept pull requests.

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41539 114
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

We're in Beta

About us Mission Statement