cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

MQTT publish error

pnali
1-Newbie

MQTT publish error

Hello,

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

10 REPLIES 10

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. tw1.PNGmqtt1.PNGI have attached the screenshot regarding this

philippk
9-Granite
(To:pnali)

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

pnali
1-Newbie
(To:philippk)

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 advancemqtt2.PNGtw2.PNGtw3.PNGtw4.PNG

philippk
9-Granite
(To:pnali)

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.

pnali
1-Newbie
(To:philippk)

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

philippk
9-Granite
(To:pnali)

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.

BrunoD
9-Granite
(To:philippk)

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:

pnali
1-Newbie
(To:philippk)

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?

BrunoD
9-Granite
(To:philippk)

It seems that even if not connected the MQTT status is still shown as connected.

Top Tags