MQTT not reading messages

Forum Home Forums Communicating with Devices MQTT not reading messages

Tagged: 

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #10502
    OtavioF
    Participant

    Hello!

    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?

    #10503
    Mikhail
    Moderator

    Hello,

    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.

    #10504
    Mikhail
    Moderator

    Note: you should publish the parameter as “/mesparam1” with slash.

    #10505
    OtavioF
    Participant

    Hello, 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/W8XuWXn

    I’ll give a try on the new MQTT driver. Hope it works!
    Thank you.

    #10514
    Mikhail
    Moderator

    Hello,

    For Rapid SCADA 5 you should use KpMqtt.dll version 5.0.4.0. Download link

    #10515
    Mikhail
    Moderator

    I’ll give a try on the new MQTT driver.

    Trying Rapid SCADA 6 seems the best option.

    #12259
    alexmtzrmz
    Participant

    Hello,

    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:

    https://imgur.com/a/dt3OhP6

    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?

    #12260
    Mikhail
    Moderator

    Hi,

    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.

    #12261
    alexmtzrmz
    Participant

    I have added the communication channel to MQTT and uploaded the configuration and the following errors appear

    https://imgur.com/a/ZNovwOC

    #12263
    Mikhail
    Moderator

    Line 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/yn2w488

    #12276
    alexmtzrmz
    Participant

    Okay, 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/hpEl9fm

    I 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?

    #12277
    Mikhail
    Moderator

    JavaScript supported by the new driver, but the names of the available functions changed.
    See the example here.

    #12278
    alexmtzrmz
    Participant

    Oh great that works just perfect, thank you so much

    #12282
    Mikhail
    Moderator

    🙂

    #12303
    alexmtzrmz
    Participant

    Hello Mikhail, I have a new question:

    In this new JavaScript that you previously shared, you use a function setValue()

    JavaScript supported by the new driver, but the names of the available functions changed.
    See the example here

    How can I access to that function in the original code?

Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.