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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!aioe.org!gz+JwLUglqIuIsOsQSSzqA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: SimpleComponents / MQTT Date: Fri, 1 Jul 2022 13:05:38 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <8d0ed195-e106-45c1-9740-07a99e404904n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="31428"; posting-host="gz+JwLUglqIuIsOsQSSzqA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:64069 List-Id: On 2022-07-01 10:51, slos wrote: > Le mercredi 29 juin 2022 à 17:00:20 UTC+2, Dmitry A. Kazakov a écrit : >>> Could you please have a look on that behaviour ? >> It means that the other side (mosquitto) dropped the connection. >> >> One possible case is when ping timeout (Keep_Alive) is set but the >> client was silent for the period of time. You should send ping before >> the timeout expires or reconnect. > Hello Dmitry, > Thanks for your answer. > I had set the "Keep_Alive" parameter : > Send_Connect (Client, "TestMQTTclient", Keep_Alive => 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 AFAIK it is a bug in mosquitto that it does not accept zero ping interval. > 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 happen if the broker was shut down. > Problem is that I could not get an information or exception in this case. It is unrelated to MQTT, just general TCP/IP behavior: 1. If one side (broker) shuts the socket down, the other side's (the client) read ends with 0 payload. 2. If it crashes, the socket is closed and nothing happens until some OS-specific timeout (might be seconds) and then the socket get shut down and see above. The second case could be improved by setting KEEP_ALIVE on the socket. 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 broker 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 sluggish clients. If you want to speed up recognition that the broker had crashed use TCP/IP KEEP_ALIVE option. Differently to ping it requires nothing from you, being implemented transparently by the TCP/IP stack. >> With SSL/TLS you could probably map users to certificates/keys and drop >> user/password, but for the server side it is easier to have them in >> order to maintain user access rights. > I use Gnoga as well and there are explanations on how to use SSL/TLS in Gnoga's documentation. > I wondered if such explanations where available to use with MQTT as well. There is nothing specific to MQTT. All protocol implementations in Simple Components (MQTT, HTTP, SMTP etc) use a connection server object. If you take one like GNAT.Sockets.Server.Secure (GNUTLS) or GNAT.Sockets.Server.OpenSSL (OpenSSL) with MQTT client/server and that 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. 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, even in latest version. > 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 AdaCore is changing the cross-reference stuff. Maybe it will get better at some point. (before getting worse first! (:-)) > By the way, thanks to your MQTT implementation, this demo application is sending SIEMENS S7 PLC data to the mosquitto broker : > https://gitlab.com/ada-for-automation/ada-for-automation/-/tree/master/demo/142%20a4a_k0_S7 Nice. P.S. In the proprietary code we rather use iTOT for SPS communication which is far more efficient. Unfortunately it cannot be included into the Simple Components. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de