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:a7b:ce8a:0:b0:3a1:8ead:2ae5 with SMTP id q10-20020a7bce8a000000b003a18ead2ae5mr2709238wmj.100.1656681754356; Fri, 01 Jul 2022 06:22:34 -0700 (PDT) X-Received: by 2002:a81:6ed5:0:b0:313:9109:b86 with SMTP id j204-20020a816ed5000000b0031391090b86mr17351482ywc.509.1656681753688; Fri, 01 Jul 2022 06:22:33 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!fdn.fr!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 06:22:33 -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: <8d0ed195-e106-45c1-9740-07a99e404904n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <2b6c606e-5803-483b-b7fb-4498e61cdc4bn@googlegroups.com> Subject: Re: SimpleComponents / MQTT From: slos Injection-Date: Fri, 01 Jul 2022 13:22:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:64070 List-Id: Le vendredi 1 juillet 2022 =C3=A0 13:05:43 UTC+2, Dmitry A. Kazakov a =C3= =A9crit=C2=A0: > On 2022-07-01 10:51, slos wrote:=20 > > Le mercredi 29 juin 2022 =C3=A0 17:00:20 UTC+2, Dmitry A. Kazakov a =C3= =A9crit :=20 > >>> Could you please have a look on that behaviour ?=20 > >> 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.=20 > > Hello Dmitry,=20 > > Thanks for your answer.=20 > > I had set the "Keep_Alive" parameter :=20 > > Send_Connect (Client, "TestMQTTclient", Keep_Alive =3D> 60.0);=20 > >=20 > > If it is not set, one gets :=20 > > MQTT client test 1 started=20 > > MQTT client connected to test.mosquitto.org=20 > > Connect rejected identifier rejected > AFAIK it is a bug in mosquitto that it does not accept zero ping interval= . > > Indeed, I get exceptions because of this line :=20 > > GNAT.Exception_Traces.Trace_On (GNAT.Exception_Traces.Every_Raise);=20 > >=20 > > I have played with mosquitto on localhost and wanted to see what would = happen if the broker was shut down.=20 > > Problem is that I could not get an information or exception in this cas= e. > It is unrelated to MQTT, just general TCP/IP behavior:=20 >=20 > 1. If one side (broker) shuts the socket down, the other side's (the=20 > client) read ends with 0 payload.=20 >=20 > 2. If it crashes, the socket is closed and nothing happens until some=20 > OS-specific timeout (might be seconds) and then the socket get shut down= =20 > and see above.=20 >=20 > The second case could be improved by setting KEEP_ALIVE on the socket.=20 > Not to confuse with MQTT's ping, which is rather a useless thing. > > So I had to add a check of the ping response in order to know if the br= oker is still there but maybe you have a better idea. > It is reverse. Ping is a sort of watchdog on the server side to drop off= =20 > sluggish clients.=20 >=20 > If you want to speed up recognition that the broker had crashed use=20 > TCP/IP KEEP_ALIVE option. Differently to ping it requires nothing from=20 > you, being implemented transparently by the TCP/IP stack. > >> With SSL/TLS you could probably map users to certificates/keys and dro= p=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= Gnoga's documentation.=20 > > I wondered if such explanations where available to use with MQTT as wel= l. > There is nothing specific to MQTT. All protocol implementations in=20 > Simple Components (MQTT, HTTP, SMTP etc) use a connection server object.= =20 > If you take one like GNAT.Sockets.Server.Secure (GNUTLS) or=20 > GNAT.Sockets.Server.OpenSSL (OpenSSL) with MQTT client/server and that=20 > will give you MQTTS. > > Unrelated, you have created your packages as childs of GNAT.Sockets. > GNAT.Sockets.Server needs access to the private part of GNAT.Sockets.=20 > That is the reason. > > Although it seems not a problem for using them, the applications can be= built, that seems to be a problem for code navigation with GNAT Studio, ev= en in latest version.=20 > > Is that a limitation of the tool or something I'm doing wrong ? > It never worked well, if you mean "go to declaration" stuff. I know that= =20 > AdaCore is changing the cross-reference stuff. Maybe it will get better= =20 > at some point. (before getting worse first! (:-)) > > By the way, thanks to your MQTT implementation, this demo application i= s sending SIEMENS S7 PLC data to the mosquitto broker :=20 > > https://gitlab.com/ada-for-automation/ada-for-automation/-/tree/master/= demo/142%20a4a_k0_S7 > Nice.=20 >=20 > P.S. In the proprietary code we rather use iTOT for SPS communication=20 > which is far more efficient. Unfortunately it cannot be included into=20 > the Simple Components. > --=20 > Regards,=20 > Dmitry A. Kazakov=20 > http://www.dmitry-kazakov.de Hi Dmitry, Thanks a lot for the provided information. Much appreciated ! Best Regards, St=C3=A9phane https://www.ada4automation.org/