From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:600c:1e13:b0:3a0:45c9:8480 with SMTP id ay19-20020a05600c1e1300b003a045c98480mr17340197wmb.51.1656665487754; Fri, 01 Jul 2022 01:51:27 -0700 (PDT) X-Received: by 2002:a25:dec8:0:b0:66d:68be:6764 with SMTP id v191-20020a25dec8000000b0066d68be6764mr13029836ybg.422.1656665486999; Fri, 01 Jul 2022 01:51:26 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 1 Jul 2022 01:51:26 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2a01:e34:ecb4:e690:9e4b:f583:2e6e:7b7; posting-account=O3LyFwoAAACc1uh60ZcOUmAGdDmGsEcV NNTP-Posting-Host: 2a01:e34:ecb4:e690:9e4b:f583:2e6e:7b7 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8d0ed195-e106-45c1-9740-07a99e404904n@googlegroups.com> Subject: Re: SimpleComponents / MQTT From: slos Injection-Date: Fri, 01 Jul 2022 08:51:27 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:64067 List-Id: Le mercredi 29 juin 2022 =C3=A0 17:00:20 UTC+2, Dmitry A. Kazakov a =C3=A9c= rit=C2=A0: > > Could you please have a look on that behaviour ? > It means that the other side (mosquitto) dropped the connection.=20 >=20 > One possible case is when ping timeout (Keep_Alive) is set but the=20 > client was silent for the period of time. You should send ping before=20 > the timeout expires or reconnect. Hello Dmitry, Thanks for your answer. I had set the "Keep_Alive" parameter : Send_Connect (Client, "TestMQTTclient", Keep_Alive =3D> 60.0); If it is not set, one gets : MQTT client test 1 started MQTT client connected to test.mosquitto.org Connect rejected identifier rejected Indeed, I get exceptions because of this line : GNAT.Exception_Traces.Trace_On (GNAT.Exception_Traces.Every_Raise); I have played with mosquitto on localhost and wanted to see what would happ= en if the broker was shut down. Problem is that I could not get an information or exception in this case. So I had to add a check of the ping response in order to know if the broker= is still there but maybe you have a better idea. > > It should be possible to use user name and password but I haven't found= how with your implementation.=20 > > Could you tell please ? > User and password are set after TCP/IP connection established during=20 > handshake (see Send_Connect). > > Of course, one should use TLS in this case. Is it feasible and how ? > Well, MQTT does not require SSL/TLS for user/password during the=20 > handshake. But logically yes, without a secure layer (e.g. provided=20 > GNUTLS or OpenSSL connection handlers) it makes little sense.=20 >=20 > With SSL/TLS you could probably map users to certificates/keys and drop= =20 > user/password, but for the server side it is easier to have them in=20 > order to maintain user access rights.=20 I use Gnoga as well and there are explanations on how to use SSL/TLS in Gno= ga's documentation. I wondered if such explanations where available to use with MQTT as well. > (In my opinion MQTT is a toy thing not be used for serious applications,= =20 > though I admit, it is hugely popular) Well, there are many toy things used for serious applications ! ;-) "Ada for Automation" being one of those... created by an Ada amateur... > > Also, how to provide a timestamp ? > Hmm, where? MQTT is totally low-level. There are only string topic and=20 > string messages, nothing else. Otherwise? if you want to send a time=20 > stamp in a message use FILETIME or UNIX time epoch and pack 8 bytes UTC= =20 > offset to (low or big endian) in the corresponding resolution. MQTT=20 > payload need not to be printable.=20 You are right. I remember having played with nodes in Node-RED where there = was something. But from : https://github.com/persan/mosquitto-ada C.Publish (Mid =3D> null, Topic =3D> "test", Payload =3D> "[" & GNAT.Tim= e_Stamp.Current_Time & "] Hej", Qos =3D> QOS_0, Retain =3D> False); or : http://mosquitto.org/man/mosquitto_pub-1.html Publish timestamp and temperature information to a remote host on a non-= standard port and QoS 0: mosquitto_pub -h 192.168.1.1 -p 1885 -t sensors/temperature -m "1266193= 804 32" The timestamp is just part of the message string. Unrelated, you have created your packages as childs of GNAT.Sockets. Although it seems not a problem for using them, the applications can be bui= lt, that seems to be a problem for code navigation with GNAT Studio, even i= n latest version. Is that a limitation of the tool or something I'm doing wrong ? By the way, thanks to your MQTT implementation, this demo application is se= nding SIEMENS S7 PLC data to the mosquitto broker : https://gitlab.com/ada-for-automation/ada-for-automation/-/tree/master/demo= /142%20a4a_k0_S7 >=20 > --=20 > Regards,=20 > Dmitry A. Kazakov=20 > http://www.dmitry-kazakov.de Best Regards, St=C3=A9phane https://www.ada4automation.org/