AndrzejBluszcz 0 Posted Saturday at 07:40 PM I would appreciate an advice on how to connect IcsMQTTClient to PicoMQTT server on ESP8266. The server does not use SSL and serves other clients normally. IcsMQTTClient is trying to connect but with no success. The server reports that an "unknown" client connected and immediately disconnected. The client keeps connecting but nothing changes. I am using the Server / Client Demo from v.9.3 with the following properties object MQTTClient: TIcsMQTTClient ClientID = 'OverbyteClient' KeepAlive = 10 MaxRetries = 8 RetryTime = 60 Clean = True Broker = False AutoSubscribe = False Host = '192.168.1.30' Port = 1883 LocalBounce = False SslVerifyCerts = False SslReportChain = False SslRevocation = False SslCliSecurity = sslCliSecNone OnMon = MQTTClientMon OnOnline = MQTTClientOnline OnOffline = MQTTClientOffline OnEnableChange = MQTTClientEnableChange OnFailure = MQTTClientFailure OnMsg = MQTTClientMsg Left = 150 Top = 397 end Should I set some specific options in the client to enable the connection? Share this post Link to post
Angus Robertson 612 Posted Sunday at 09:45 AM Sorry, no simple answer, the MQTT component was contributed, and only tested against itself. I don't have any other local MQTT servers to test against, although it was tested against some public servers. I'm aware there are various versions of MQTT and some servers are non-standard, questionable whether ICS should break the protocol to work with devices that don't follow it, please search back in this forum, I think it's been discussed before. Otherwise, you'll need to use Wireshark or something to see how the other clients are communicating with the server, and change the component to match that. Angus Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 07:28 PM Thank you for the message. I have tried to capture the transmissions and it seems that IcsMQTTClient uses MQIsdp protocol (MQTT v.3.1) and the connection request has header flags 0x12 while another client, that connects successfully uses MQTT v.3.1.1 and the header flags 0x10. The PicoMQTT server uses MQTT v.3.1.1. Is there a way to change the behaviour of the IcsMQTTClient? I tried to replace 'MQIsdp' with 'MQTT', but that made things worse. The message is not recognised as MQTT command. Andrzej Share this post Link to post
Mark- 29 Posted Sunday at 07:43 PM Just now, AndrzejBluszcz said: Thank you for the message. I have tried to capture the transmissions and it seems that IcsMQTTClient uses MQIsdp protocol (MQTT v.3.1) and the connection request has header flags 0x12 while another client, that connects successfully uses MQTT v.3.1.1 and the header flags 0x10. The PicoMQTT server uses MQTT v.3.1.1. Is there a way to change the behaviour of the IcsMQTTClient? I tried to replace 'MQIsdp' with 'MQTT', but that made things worse. The message is not recognised as MQTT command. Andrzej The packet fixed header byte for "Connect", regardless of 3.1 or 3.11, is 0x10. The lower 4 bits of the packet fixed header are reserved. The packet fixed header byte for 3.1: Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 07:48 PM I am trying to find what sends the connect command but no success so far. Do you know where should I look for it? Andrzej Share this post Link to post
Mark- 29 Posted Sunday at 07:51 PM Sorry no. I do not use it. I would search for the 0x12 ($12), or the text of the protocol name. Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:01 PM I think it is TIcsMQTTParser.SendConnect procedure. And it makes a header with qtAT_LEAST_ONCE, which is incorrect. I am trying to change it to qtAT_MOST_ONCE and see what happens. Andrzej Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:13 PM No. It didn't help. The header is correct now, though. Share this post Link to post
Mark- 29 Posted Sunday at 08:20 PM What is the response? Or no response? Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:22 PM It is exactly as before with one exception. The header flags are 0x10 now. Share this post Link to post
Mark- 29 Posted Sunday at 08:26 PM (edited) Just now, AndrzejBluszcz said: It is exactly as before with one exception. The header flags are 0x10 now. What does that mean? A trace using Wireshark has no response from the broker? Edited Sunday at 08:26 PM by Mark- Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:30 PM There is no response from the broker. However the broker fires OnDisconnect event. That is the broker fires OnConnect and OnDisconnect in quick succession. Share this post Link to post
Mark- 29 Posted Sunday at 08:34 PM Just now, AndrzejBluszcz said: There is no response from the broker. However the broker fires OnDisconnect event. That is the broker fires OnConnect and OnDisconnect in quick succession. Yeah IIRC, a broker can select to, not answer a connect message or return an error message. Does the broker documentation state the version(s) or MQTT it supports? Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:37 PM PicoMQTT supports MQTT version 3.1.1. IcsMQTTClient supports MQIsdp version 3.1 (MQTT v.3.1). So the versions on both sides are different and this the only thing that I see at the moment. Share this post Link to post
Mark- 29 Posted Sunday at 08:48 PM There are a few commercial MQTT clients. Or you could write your own code. The MQTT protocol is not very complicated, by design. Share this post Link to post
AndrzejBluszcz 0 Posted Sunday at 08:50 PM OK. Will see. Thank you for you time and help, Mark. Andrzej Share this post Link to post
Mark- 29 Posted Sunday at 08:55 PM Just now, AndrzejBluszcz said: OK. Will see. Thank you for you time and help, Mark. Andrzej You are welcome. Share this post Link to post
Angus Robertson 612 Posted Monday at 09:13 AM I would assume the difference between 3.1 and 3.1.1 is relatively small, so it should be easy to change the ICS component. But we'd need to know what that difference is, and a server to test against. Angus Share this post Link to post
omnibrain 15 Posted Monday at 10:04 AM I think first and foremost it should work against Eclipse Mosquitto, as it's more or less the reference implementation. https://test.mosquitto.org/ Share this post Link to post
Angus Robertson 612 Posted Monday at 11:01 AM I get Connection NOT AUTHORISED connecting to test.mosquitto.org on ports that say unauthenticated, I'll spend a few minutes looking to see why, but my knowledge of MQTT is zero, and I don't propose to learn the protocol, maintenance of the ICS MQTT component really needs to be done my users that understand and use MQTT. Angus Share this post Link to post
Angus Robertson 612 Posted Monday at 05:37 PM I've installed the Mosquitto Broker server locally, and it works OK against the ICS MQTT client. Our sample currently always adds a default username/password, and this was upsetting test.mosquitto.org on the unauthenticated port, so the sample now allows them to be set specifically, and leaving them blank connects OK to test.mosquitto.org, which is also now on a ComboBox dropdown to make testing easier. But this does not explain why PicoMQTT fails (unless it's also authentication). Mosquitto supports 3.1, 3.1.1 and 5, I'll see if I can disable 3.1. There is a comment in the conf file about clients connecting with 3.1.1 and a zero length client Id so the server allocates one, perhaps this explains the difference. Angus Share this post Link to post
AndrzejBluszcz 0 Posted Monday at 07:17 PM Thank you for your interest in my case. I am also not an expert in MQTT but at home I run a few little servers and clients on ESP microcontrollers. When I am connecting PicoMQTT client to PicoMQTT server there is no problem. I can also connect MQTT client on my iPhone and a commercial iotMQTTClient. In all cases I have empty usernames and passwords and no SSL. PicoMQTT supports v.3.1.1. Andrzej Share this post Link to post
Angus Robertson 612 Posted 18 hours ago I'm updating the ICS MQTT client for v3.1.1 at the moment, should be this week. Not planning v5 at the moment, that is totally different. Most servers still support 3.1.1. Angus Share this post Link to post
AndrzejBluszcz 0 Posted 13 hours ago Thank you. I am looking forward to it. Andrzej Share this post Link to post