good mqtt client lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- promisetom · 2021-04-29 21:45 Hi All, Has anyone used an MQTT client that works well and is reliable. I have tested a few but the system crashes with most components. Tom ---------------------------------------------------------------------- af0815 · 2021-04-30 17:40 I use it from https://github.com/bkeevil/mqtt.git It looks very stable. For me, i have created a package with lesser depenencies. ---------------------------------------------------------------------- promisetom · 2021-05-01 22:30 I did test that out and it locked the whole system up. All I need is a simple client to read data from an esp8266 and my weather station. Only data once a minute or so. Is your poackage available in the public domain. (i.e. me) ---------------------------------------------------------------------- avra · 2021-05-01 22:50 Alternative: https://github.com/ZiCog/mqtt-free-pascal ---------------------------------------------------------------------- Tuxscreen · 2022-02-02 11:56 I am hijacking this thread, because it's the latest in my list about "mqtt" (but also older than 120days) I am searching for help. I tried almost all referenced mqtt component suites, but all of them seem to break on current mosquitto servers (maybe the implemented mqtt protocol checks are now more strict?) Most of the times a connection is made, but after some publishs, the connection is dropped because of an error 'insufficient data' (I crosschecked with mqtt-spy and mqtt.fx - both work flawlessly) Has anybody seen the same problems, and has found a solution? BR Marc ---------------------------------------------------------------------- af0815 · 2022-02-02 14:33 Quote from: Tuxscreen on February 02, 2022, 12:56:13 pmI tried almost all referenced mqtt component suites, but all of them seem to break on current mosquitto servers What mosquitto server and suit Excact, please with more details - Win / Linux / MacOs or whatever. ---------------------------------------------------------------------- Thaddy · 2022-02-02 16:08 Quote from: avra on May 02, 2021, 12:50:12 amAlternative: https://github.com/ZiCog/mqtt-free-pascal Did you see that code? Sorry Avra but this is someone that hits is own head with a hammer to avoid him making mistakes, gives himself a compliment, hit his head again and then distributes it accidentally so he can hit his head again. The original was much cleaner and less prone to head-ache. Anyway MQTT is a very simple protocol. That code should be left alone. ---------------------------------------------------------------------- Tuxscreen · 2022-02-02 17:14 Quote from: af0815 on February 02, 2022, 03:33:26 pmQuote from: Tuxscreen on February 02, 2022, 12:56:13 pmI tried almost all referenced mqtt component suites, but all of them seem to break on current mosquitto serversWhat mosquitto server and suit Excact, please with more details - Win / Linux / MacOs or whatever. Hi Andreas, thanks. Most trials I did with the components from Bond Keevil's mqtt (github) and a derived version with lesser dependencies. Test setup: Compiling and testing with Windows10/Lazarus2.2.0-64bit (latest) Tested against: 1) official mosquitto broker (test.mosquitto.org:1883) 2) multiple versions of mosquitto on local machine (mosquitto v2.0.14 and mosquitto v1.6.13) All setups are first tested with mqtt-spy and mqtt.fx and work flawlessly. Mqtt-demo-app (provided with Bond Kevils mqtt) gives me the following errors [...] Client has connected [...] (i subscribe to "#" or "$SYS/#") [...] after some published messages I get: Bail: Insufficient data for packet - Client has been reset. (the errors occur independently on my local machine broker or on the official testservers broker. References: (github) https://github.com/bkeevil/mqtt (github same Lib, but less depends) https://github.com/afriess/mqtt/tree/LessDepends https://github.com/ZiCog/mqtt-free-pascal see my results below ---------------------------------------------------------------------- af0815 · 2022-02-02 17:44 Thx for the information. The last updates of Kevils repository are 3 yrs old. So i think some changes in mqtt and its security are missed. My last information is 2 yrs old, because i have used the component. Actual i have only some tests with debian based implementation and they works by the customer. So the information is indeed interesting. I will have an eye if the customer reports an issue. Ok, the "less depends " its me. BTW. I am in the german forum too - my native language ---------------------------------------------------------------------- Tuxscreen · 2022-02-02 17:48 Here come my test results for (https://github.com/ZiCog/mqtt-free- pascal) (local machine broker mosquitto v2.0.13) Example connects and bails out because of an malformed packet (see below or attachment screenshot) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  (broker log):1643823735: New client connected from 127.0.0.1:53393 as dMQTTClientx982 (p1, c1, k40).1643823735: Will message specified (20 bytes) (r0, q0).1643823735:     lwt1643823735: Sending CONNACK to dMQTTClientx982 (0, 0)1643823735: Received SUBSCRIBE from dMQTTClientx9821643823735:     /ivuvio/# (QoS 0)1643823735: dMQTTClientx982 0 /ivuvio/#1643823735: Sending SUBACK to dMQTTClientx9821643823735: Client dMQTTClientx982 disconnected due to malformed packet.1643823747: New connection from 127.0.0.1:53394 on port 1883. (program log):embeddedApp MQTT Client.RX_START: Operation would blockRX_START: 10035loop...RX_START:RX_START: 0SUBACK: 1, 0TMQTTClient.OnRTTerminate: Thread.Terminated.embeddedApp: Error: PingReq Failed.TMQTTClient.ForceDisconnectRX_START: Operation would blockRX_START: 10035loop...RX_START:RX_START: 0SUBACK: 2, 0TMQTTClient.OnRTTerminate: Thread.Terminated.  I suppose, this was once "working" code. But as the mqtt protocol got some hardening, and they hardened the rules for checking fields, now these mqtt-clients (or libs) do not work any longer. ---------------------------------------------------------------------- af0815 · 2022-02-02 17:52 I see, some of the hardening is not in the repositories. So most (or all) of the repos need rework. ---------------------------------------------------------------------- Tuxscreen · 2022-02-02 19:15 Quote from: af0815 on February 02, 2022, 06:52:00 pmI see, some of the hardening is not in the repositories. So most (or all) of the repos need rework. Do you remember which mosquitto broker version last worked for you? Maybe you can tell me the month+year when you tested this stuff? ---------------------------------------------------------------------- af0815 · 2022-02-02 20:11 Two years ago with a version on a raspbian system, because i need it for a power measurement system. The power meter was only able to communicate with mqtt. ---------------------------------------------------------------------- Tuxscreen · 2022-02-03 00:29 I will test some older version of mosquitto... Keep you posted! ---------------------------------------------------------------------- avra · 2022-02-04 07:21 Quote from: Thaddy on February 02, 2022, 05:08:10 pmQuote from: avra on May 02, 2021, 12:50:12 amAlternative: https://github.com/ZiCog/mqtt-free-pascal Did you see that code? Sorry Avra but this is someone that hits is own head with a hammer to avoid him making mistakes, gives himself a compliment, hit his head again and then distributes it accidentally so he can hit his head again. The original was much cleaner and less prone to head-ache. Anyway MQTT is a very simple protocol. That code should be left alone. Hahahaha, my bad. I didn't inspect it at all. I have just blindly forwarded a stored pointer to an alternative MQTT repo. Thanks for reviewing it and assigning nil to it. ---------------------------------------------------------------------- desliem · 2022-02-21 20:16 @Tuxscreen: Have you tried the Free Pascal conversions of the libmosquitto header file by Károly Balogh (chainq) at https://github.com/chainq/mosquitto-p? Of course the libmosquitto MQTT client library must be installed on the system, but I have had success with it, building a couple of MQTT clients that work in Linux and Windows (see https://github.com/sigmdel/).  The clients have been run against mosquitto version 1.5.7 (protocol v3.1.1) broker. Cursory tests done just today showed that lazmqttc appears to work without problems with mosquitto version 2.0.11 (protocols  v5.0/v3.1.1/v3.1) as long as authentication is handled correctly (see https://mosquitto.org/documentation/migrating-to-2-0/#listener- behaviour-changes).