10 Replies Latest reply on Nov 10, 2016 11:39 AM by pnali RSS
    pnali Explorer

    MQTT publish error



    I have referred the following link to publish the message in thingworx :

    MQTT support in ThingWorx

    but while publishing from mosquitto in command prompt I got an error saying"unable to connect(lookup error)".

    Can anyone help me where I am getting wrongmqtt.PNG

      • Re: MQTT publish error
        fbailleux Apprentice


        Can you check if the MQTT-example is referenced in your Host file with the correct IP address ?
        Can you also try to use localhost or (replace MQTT-example) if your mosquitto server is installed on your local computer.




          • Re: MQTT publish error
            pnali Explorer

            Thanks for replying.


            I used localhost and there is no error. But when coming to thingworx  it is not displayed in property.I have given server name and port name as test.mosquitto.org and 1883 respectively. tw1.PNGmqtt1.PNGI have attached the screenshot regarding this

              • Re: MQTT publish error
                philippk Explorer



                from your screenshots I understand the following:

                - you have installed a Mosquitto MQTT broker on your localhost and you can successfully publish message to this broker via the command line - this is all independent from Thingworx

                - you have installed Thingworx on localhost and have configured a MQTT Thing, so MQTT (client) extension should be configured to listen on the address and port of your broker

                - I see that you have configured this broker in the Composer screen with test.mosquitto.org on port 1883, but from my perspective the broker is also on localhost, so I would change the "serverName" to localhost or respectively.

                - additionally (not shown in your screenshots) you also need a Property (typically of type STRING) defined on your MQTT Thing that matches the name in your "Property to MQTT topic mappings", so "temperature" in your example.




                  • Re: MQTT publish error
                    pnali Explorer

                    hello Philipp,

                    Thanks for replying. I tried the server name with both localhost and I have given temperature as type NUMBER. but still no response. Is the Clientformat given in correct way? Do I need to give any password because in Mosquitto i havnt given any password. Can you suggest where I am getting wrong.


                    Thanks in advancemqtt2.PNGtw2.PNGtw3.PNGtw4.PNG

                      • Re: MQTT publish error
                        philippk Explorer

                        a bit difficult to troubleshoot remotely, but at least I see that your Thing in Thingworx shows "isConnected=true", so it looks as if your MQTT extension is successfully connected to your (local) MQTT broker.


                        So I doubt that the extension supports all property types, but I think it interpretes MQTT messages as STRING per default, not sure that you can transform to number directly, so let's test this first - can you change your property temperature to type STRING ?


                        Have you checked the property value in Composer after publishing (with refreshing) or are you cheking the property values by a separate mashup ?

                        Additionally I would recommend that you also test your broker independently from thingworx, so please check that your published messages are also received by the broker with a standard MQTT client, like described in Franck's post with the commandline tool.