dustin / mqtt-hs Goto Github PK
View Code? Open in Web Editor NEWHaskell MQTT client.
License: BSD 3-Clause "New" or "Revised" License
Haskell MQTT client.
License: BSD 3-Clause "New" or "Revised" License
app/example/Main.hs
so that the client connects to mqtt://localhost:1883
.The same as when using the mosquitto broker.
The client disconnects after publishing the first message with QoS > 0
It appears that parsePacket
(Network.MQTT.Types
) results in
ParseError {errorContexts = ["240"], errorMessage = "Failed reading: satisfy", errorPosition = 1:90 (89)}
(when called from doSrc
in Network.MQTT.Client
) causing the client to disconnect.
Adding an UnknownPkt
constructor prevents the error (but doesn't solve the problem, of course).
I'm not yet sure if EMQ X is sending bad packets, or if the issue is on net-mqtt
's side...
Hi,
what would it take to create a haskell MQTT server using mqtt-hs?
i have an REST API server using mongo as a database.
I added some time ago some MQTT endpoints to the server, using mqtt-hs.
It is just filtering MQTT requests, then forwarding them to a Mosquitto backend: https://github.com/Waziup/waziup-api/blob/master/src/MQTT.hs
However, I would like to get rid of the Mosquitto. How complex would that be? I guess I have to implement features such as maintaining a list of subscribers. I don't need the full MQTT specification, just what it takes to make a small REST + MQTT API server, with a mongo backend.
Any chance to have a library "mqtt-broker-hs" sometimes, handling the requests (like Mosquitto)?
Thanks
I see the only option in this library is to use the connectURI to actually connect to the MQTT, is it possible to expose a general connect option where we can manually fill in the required information for the connection? Thanks. I am new to Haskell so I can try to implement this in a PR if you think it would be beneficial.
I have run into the problem where received messages are sometimes handled out of order, due to the fact that all callbacks are invoked asynchronous (similar to #12, but in my code).
While asynchronous callbacks might be correct for some use cases, they will randomly break every use case that relies on ordered messages. They are also problematic when messages arrive at a rate that is higher than what can be processed by user code.
I think the library user should be responsible for forking during the callback when it is required. Alternatively MessageCallback
could be extended to have async- and synchronous variants.
And also thank you very much for writing this library!
Using uri-bytestring would be much better for constructing URIs. See for example: haskell-servant/servant#139
https://hackage.haskell.org/package/uri-bytestring-0.1.5/docs/URI-ByteString.html
Just a mild annoyance, but the naming is quite confusing:
It would nice to harmonize the namings.
this line should be added
{-# LANGUAGE OverloadedStrings #-}
to the 2 examples (Publish and Subscribe )in the Homepage and ReadME
without this line does not compile ;(
Hi,
Apparently a version 0.8.2.3
was deployed on Hackage and Stackage a couple days ago, however it appears the last visible commit here happened about 2 months ago.
The cabal file I see here says 0.8.2.2
.
Is this intentional ? I'm trying to confirm nothing was compromised here.
The return type of a SimpleCallback
and OrderedCallback
is IO ()
. These IO
actions are subsumed in the IO MQTTClient
return type of connectURI
. However, the user might want to perform different action depeding on the content of a message, e.g. log messages upon receiving malformed messages.
It would be a major overhaul, but very useful, if net-mqtt provided a mechanism for structured error handling and reporting. For example, the MQTTClient
type could expose a TChan
that callbacks can write to and ambient applications can read from, so that worker threads and the ambient application can exchange messages in a structured way.
It's possible for a broker to send aliased QoS 2 messages such that the first message defines an alias and the rest use it, but the notification is ready for one of the latter messages before the alias definition is stored.
Inbound messages are processed asynchronously and can fall out of order when there's a large number inbound. The right thing to do is probably to make this all be synchronous and preserve ordering. The actual message processing itself should still be asynchronous so user code doesn't block processing, but I don't need to keep QoS 2 processing state in threads, and I don't need to asynchronize the inbound processing so early.
Hey, Dustin! I was wondering if there were any plans on adding http proxy support for port 1883. I work behind an enterprise proxy and it seems like the application hangs on connectURI
because of the proxy issue. I know that the golang library has proxy support.
https://github.com/eclipse/paho.mqtt.golang
Wondering if we could add it here as well?
Thanks!
The package is still broken on nixpkgs due to #16.
I have fixed the problem for my personal deployments so this is not urgent, but I would prefer to upstream the change. There are two options:
I'm fine with either option, but if we apply a jailbreak to the package I can't help with future version bumps (I wouldn't notice them).
e.g. for setting custom CA certificates to use.
From what I can tell, this library uses tlsClientConfig
, which only uses the TLSSettings
default value.
Hi, it would be great if you could add this library to Stackage so that we can all keep an eye on its stability.
If you are too busy to maintain it I offer myself as co-maintainer.
Sorry. I've found the solution.
Hello,
Thanks for maintaining this very useful package.
When we restarted our broker the other day, we realised net-mqtt didn't reconnect.
I was wondering whether it would be feasable for net-mqtt
to try to reconnect, and maybe republish messages that didn't get a PUBACK
from the old broker connection?
Judging by this, paho-mqtt
seems to have logic to reconnect, although I'm not sure what guarantees you get in such a case.
Would it be possible to export the constructors for Topic
and Filter
? The mkTopic :: Text -> Maybe Topic
is the only method provided by the API as of now for creating a topic, but there are some cases where I'd like to create a Topic
without handling the alternative Nothing
case since I'm certain the Text
string does not contain any reserved characters.
I believe exporting the Topic
and Filter
constructors with a cautionary note and a strong suggestion to use mkTopic
where possible would be an improvement to the package.
Hi,
Running the most basic example from https://github.com/dustin/mqtt-hs/blob/master/app/Main.hs.
I am getting thread blocked indefinitely in an STM transaction
caused by
print =<< subscribe mc [("tmp/topic1", QoS0), ("tmp/topic2", QoS0)]
Am I missing something?
GHC - 8.6.5
Where can I ask questions about this package?
Maybe the source of my problem is a lack of understanding of mqtt..
The mqtt broker is mosquitto. Some not Haskell processes publish message on the broker.
Every week I want to log in and get all persistent messages for a topic and then disconnect. The broker should persist the messages from that week.
The Haskell client logs in (Qos2 and _cleanSession=false, protocol50, _retainHandling= SendOnSubscribe) and subscrices to the topic.
Every time I log in I get another assigned client identifier and the broker starts a NewSession. That's not what I want. To get old persistent messages the clientId should stay the same?
Where can I set the clientId?
I wonder whether I have to subscribe after the first time. The broker should know what to send, without subscribing by the client, or...?
Thanks,
Kees
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.