Forum Home › Forums › Communicating with Devices › MQTT not reading messages
- This topic has 13 replies, 3 voices, and was last updated 4 days, 1 hour ago by
Mikhail.
-
AuthorPosts
-
August 19, 2022 at 8:17 pm #10502
OtavioF
ParticipantHello!
I started using MQTT recently and I’m struggling to make it work with RapidScada.
I used the great YouTube video explaining how to setup, which allowed me to successfully connect to my MQTT broker. However, when I use a client (such as mqtt spy) to publish a number to test, RapidScada is not reading it. It’s not showing on the Device status.The line that contains the MqttSubTopics looks like this:
<Topic TopicName="/mesparam1" QosLevel="0" NumCnl="666"/>
My input channels related to the MQTT device looks like this:
Number - 666 Active - checked Name - mqttparam1 Channel Type - Calculated real Device - MQTTCascata Signal - 1
On the device status:
Current device tags data +--------+------------+-------+---------+ | Signal | Name | Value | Channel | +--------+------------+-------+---------+ | ******** GroupMQTT ****************** | +--------+------------+-------+---------+ | 1 | /mesparam1 | --- | 666 | +--------+------------+-------+---------+
There is communication between RapidScada and MQTT broker, because on Line Log I get numerous “Send packet” and “Receive packet”. So connection is not a problem.
What am I missing?August 22, 2022 at 6:33 am #10503Mikhail
ModeratorHello,
Could you check the MQTT driver version in the dll file properties?
Please copy a bigger part of the configuration file and communication line log.Another option is to try the new MQTT driver included in Rapid SCADA 6 Beta. It was redesigned, and provides handy UI for configuring.
August 22, 2022 at 6:35 am #10504Mikhail
ModeratorNote: you should publish the parameter as “/mesparam1” with slash.
August 22, 2022 at 12:12 pm #10505OtavioF
ParticipantHello, Mikhail.
On the dll file properties, version is 1.0.0.0, last modified at july 28, 2020.
Bigger part of the configuration file, excluding MQTT server username and password:
<?xml version="1.0" encoding="utf-8"?> <DevTemplate> <MqttParams Hostname="node02.myqtthub.com" ClientID="---" Port="1883" UserName="otaviofolharini" Password="---"/> <RapSrvCnf ServerHost="127.0.0.1" ServerPort="10001" ServerUser="ScadaComm" ServerPwd="12345"/> <MqttSubTopics> <Topic TopicName="/mesparam1" QosLevel="0" NumCnl="666"/> </MqttSubTopics> <MqttPubTopics> </MqttPubTopics> <MqttPubCmds> </MqttPubCmds> <MqttSubCmds> </MqttSubCmds> <MqttSubJSs> </MqttSubJSs> </DevTemplate>
The communication line log:
2022-08-22 08:52:39 Initialize communication line 10 "MQTT" Send packet Send packet Connection established 2022-08-22 08:52:42 Start communication line 10 "MQTT" 2022-08-22 08:52:42 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Send packet 2022-08-22 08:52:43 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Receive packet 2022-08-22 08:52:43 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Receive packet 2022-08-22 08:52:44 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Receive packet 2022-08-22 08:52:44 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Send packet 2022-08-22 08:52:44 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Send packet 2022-08-22 08:52:45 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Send packet 2022-08-22 08:52:45 Communication session with the Device 5 "MQTTCascata", type: KpMqtt Receive packet [...]
Device info:
Device 5 "MQTTCascata" ---------------------- DLL : KpMqtt State : normal Comm. session : 22/08/2022 08:54:30 Command : time is undefined Comm. sessions (total / errors) : 295 / 0 Commands (total / errors) : 0 / 0 Requests (total / errors) : 146 / 0 Current device tags data +--------+------------+-------+---------+ | Signal | Name | Value | Channel | +--------+------------+-------+---------+ | ******** GroupMQTT ****************** | +--------+------------+-------+---------+ | 1 | /mesparam1 | --- | 666 | +--------+------------+-------+---------+ No archive data No events No commands
Here is a print from MyQtt Web Interface, that allowes me to publish messages to topics.
https://imgur.com/W8XuWXnI’ll give a try on the new MQTT driver. Hope it works!
Thank you.August 23, 2022 at 9:38 am #10514Mikhail
ModeratorHello,
For Rapid SCADA 5 you should use KpMqtt.dll version 5.0.4.0. Download link
August 23, 2022 at 9:38 am #10515Mikhail
ModeratorI’ll give a try on the new MQTT driver.
Trying Rapid SCADA 6 seems the best option.
March 17, 2023 at 4:15 pm #12259alexmtzrmz
ParticipantHello,
I was able to create the same conection in Rapid SCADA 5
but then I tried it similarly on Rapid SCADA 6 and it did not work
I tried assigning MQTT as device type and this error appeared:
Then I tried to set it as MQTT Client and I stablished all the parameters with the broker, just as I had done on the v5 and the status of the Line remains undefined
Could I please get some support?
March 17, 2023 at 4:48 pm #12260Mikhail
ModeratorHi,
You should choose “MQTT Client” for a device, not “MQTT”.
MQTT Client is the new driver for v6.
Don’t forget to set Communication Channel = MQTT client in the line options.
In case of issues, please provide links to screenshots of your settings and errors.March 17, 2023 at 5:20 pm #12261alexmtzrmz
ParticipantI have added the communication channel to MQTT and uploaded the configuration and the following errors appear
March 18, 2023 at 7:09 am #12263Mikhail
ModeratorLine State – Undefined status is a minor bug. Thank you that you found it. Will be fixed in the next release.
Try another broker that works for me: https://ibb.co/yn2w488March 21, 2023 at 4:34 pm #12276alexmtzrmz
ParticipantOkay, great, thanks for the consideration
I am able now to communicate and receive one data, as object
The problem now is that I can’t read arrays just as I could in the V5
What I did in the v5 was to use the JavaScript file that was in the CommConfig to process the incoming data
https://imgur.com/a/hpEl9fmI edited that file with my own code to read arrays
// Data example
// { “Val0”: 12.3, “Val1”: 45.6 …}
var data = JSON.parse(InMsg);
// Fill the array with consecutive numbers
for (let i = 0; i < data.length ; i++) {
jsvals[i].Stat = 1 ;
jsvals[i].Val = data[i] ;
jsvals[i].TagName = i.toString() ;
}
mylog(“Script completed successfully”);That code works good in v5, how could I do the same in v6?
March 21, 2023 at 5:14 pm #12277Mikhail
ModeratorJavaScript supported by the new driver, but the names of the available functions changed.
See the example here.March 21, 2023 at 7:11 pm #12278alexmtzrmz
ParticipantOh great that works just perfect, thank you so much
March 22, 2023 at 12:52 pm #12282Mikhail
Moderator🙂
-
AuthorPosts
- You must be logged in to reply to this topic.