Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello,
I have referred the following link to publish the message 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 wrong
Hi,
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 127.0.0.1 (replace MQTT-example) if your mosquitto server is installed on your local computer.
Regards,
Franck
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. I have attached the screenshot regarding this
Hi,
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 127.0.0.1 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.
BR
Philipp
hello Philipp,
Thanks for replying. I tried the server name with both localhost and 127.0.0.1. 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 advance
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.
I tried with changing to string from number but still the issue is same. I dont know where I am going wrong.Can you suggest any work around
Thanks,
Preethi
As stated, I would first confirm that the broker receives the message with an independent client. Additionally I would check the Thingworx Application log to see if their are any errors related to this activitiy.
Hi,
You can try an online broker if you want :
http://www.hivemq.com/try-out/
I just checked and it works fine for me. The comment of Philipp regarding the string format is correct.
In order to help you save some time follow the screenshots settings:
I tried independently using two different command prompts for publishing and subscribing and it is working fine.can you help in how can we check application logs?
It seems that even if not connected the MQTT status is still shown as connected.