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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

MQTT support in ThingWorx


MQTT support in ThingWorx


I wish to know more about the current available MQTT support in ThingWorx. I understand it is available through MQTT extension, but it doesn't seems to have a detailed documentation on it in this community.

Can you please explain the level of integration of MQTT support in ThingWorx, and how does it communicate to the MQTT device through ThingWorx, and if any message broker involved etc.?

Also, it is much appreciated if you could point me to any available detailed documentation/link and if there is any sample demo ThingWorx application that could be referred to.

Thanks in advance.


Same request,

Wondering why MQTT_Conenction and MQTT_subscriber dont have services...

A quick start quide/video would help

I'll add this as a third request for some samples of an MQTT connectivity subscribe and publish event.  How do you accomplish this from Thingworx?  A sample or video would be very much appreciated. Thanks, Rob


Here's a steps by steps:

Installing an MQTT broker

     The MQTT ThingWorx extension acts as an MQTT client, so in order to test it we need to install a local broker.
     One such open-source broker can be downloaded from

Download the binary Windows installation: mosquitto-X.Y.Z-install-win32.exe from the download page and install it locally.

     Mosquitto depends on PThreads and OpenSSL, but does not redistribute them, so you need to download them following the instructions      in the readme-windows.txt included in the package.

     Please note that the Mosquitto build is 32-bit, so you must download 32-bit versions of both PThreads and OpenSSL DLL’s.

     After downloading and installing those two dependencies, you’ll maybe notice the famous DLL hell come true: your Windows system is      already spammed with all sorts of OpenSSL libraries, dropped in the PATH by various applications that you might have been installed in      the past: some of them are 32-bit, some 64-bit. Since we want to be sure that we use a 32-bit version (and probably the one we have just      downloaded), you have to adjust the PATH as seen by Mosquitto, remove all directories from the path that have nothing to share with      mosquitto, and add the new one. While you might think you can copy the new DLL’s to the Mosquitto folder, you’ll soon realize that      adjusting the PATH is a much better and resilient option.

     This is the PATH that I’ve set in the Command Prompt before running Mosquitto:

     Set PATH=C:\Windows\system32;C:\Windows;D:\opt\OpenSSL-Win32;D:\opt\OpenSSL-Win32\bin;D:\opt\pthreads-w32-2-9-1-release\Pre-built.2\dll\x86

Testing Mosquitto

     Before configuring the MQTT extension, test your local Mosquitto instance, as follows.
     Open three command prompts and set the PATH in them according to the previous section:


     - Command Prompt for the broker:

o   Run mosquitto –v to start the broker in verbose mode

     - Command Prompt for the client that subscribes to a topic

o   Run mosquitto_sub -v -i subclient-q 2 -t random/temp to start the subscriber client in verbose mode, using the subclient ID, quality of service 2, and topic random/temp

o   You will see that the broker logs a subscription request in its standard output

     - Command Prompt for the client that publishes a message to a topic

o   Run mosquitto_pub -q 2 -t random/temp -m 33 to start the publisher client with quality of service 2, topic random/temp, and message 33

o   You will see that the broker logs a publish request in its standard output, as well as the subscriber client

Testing the MQTT extension in Thingworx

  • Download the MQTT extension from the PTC marketplace
  • Import the saved zip file from the Import/Export menu tab (Import/Export > Extension > Import) in the Thingworx composer.
  • Create a new thing and choose the MQTT template when asking for Thing Template in the General Information page


  • Create the different properties related to the topic you wish to use (publish and subscribe) on the Properties page (e.g. temperature).

  • To record the value history of a property checks the Logged box and add/create the value stream name in the General information page.
  • Auto mapping Settings on the Configuration page controls whether you want Thingworx to automatically generate topic name(s) based on a pattern that can include server name {s}, thing name {t} and property name {p} token(s)


  • Property to MQTT topic mapping paragraph allow you to map the topic (e.g. temp/random) with the property name (e.g. temperature) and publish and/or subscribe check box.


  • Connection Settings requires, at least, the serverName (e.g., the serverPort (e.g. 1883) and a qos (Quality of Service) value from 0 to 2:
    • 0: The broker/client will deliver the message once, with no confirmation.
    • 1: The broker/client will deliver the message at least once, with confirmation required.
    • 2: The broker/client will deliver the message exactly once by using a four step handshake.



  • Save your thing and test the connection by checking the isConnected service (value = true) on the Properties page - MQTT (ThingTemplate) - Properties paragraph


    (Note : I installed the Mosquitto client, subscribe to the topic and publish a message with value = 20)

  • Once validated create a new mashup:
    • mashup type = Page and Layout Options = Static
    • add three widget: a gauge, a LED Display and a Time Series Chart
    • add an Entity by clicking on the Green Plus button on the upper right corner of the Entity area and choose the previously created thing.
    • add the GetProperties service, check the Mashup Loaded box, add the QueryPropertyHistory without checking the Mashup Loaded box and click Done button.
    • expand the GetProperties service and drag and drop your property (e.g. temperature) to both gauge and LED Display widgets (Select Binding Target = data)
    • expand the QueryPropertyHistory service and drag and drop the All Data parameter to the Time Series Chart widget (Select Binding Target = data)
    • save the mashup, give it a name and click on the View Mashup button.


Here’s the result:


If you want to get more information about the Mosquitto client please check the following website:



To test the extension without installing a MQTT broker please check the following website:



I hope this information helps you.
Please let me knowif you have question or need more information about this topic.

Franck Bailleux

Thank you!

I've finally got a Thing running with 2-way communication to a public MQTT broker thanks to this walkthrough!

BTW, I could not get the MQTT ThingTemplate method to work -- my Thing failed to initialize.  Instead, I used the pair of MQTTConnection and MQTTSubcriber and that alternate method worked quite easily.  If I learn more about the initialization issue, I'll post it here.

For a public MQTT broker, I'm using:

And I'm monitoring/testing with this very nice web-based client:

I'll be working with MQTT I/O a lot more in the next few days.  Thanks for getting me off the ground.

Dan Thornton

ThingWorx Newbie

hello Franck,

I tried the steps given but after publishing in mosquitto command promt I am not able view the temperature in thingworx. the isConnected service value is also false. I have given same serverName ( and the serverPort (1883).

Can you suggest where I went wrong

while publishing itself i am getting error saying "unable to connect(lookup error)". can anyone help how to proceed further

Hi Franck,


         i tried the same thing which you mentioned, but i am facing problem in thingworx running on (windows8) and the mosquito broker on ubantu ThingWorxProperty.PNG

i am able to get the (isConnected=true)  but when publishing message i am unable to get it in the thing and gives connection refused in ubantu terminal


where given the ip and "Thingworx" as Topic and MQTT as a message to send..



can you tell me, am i missing something??

unable to set value of temperature property


Could anyone tell that how much messages can thingworx MQTT client handled simultaneously. I mean for example there are 2 million connected devices to thingworx and all are communicating to thingworx and sending messages at same time. Could thingworx MQTT client can handle this scenario?


Hello, how to publish json message to a multiple properties on a single topic ? please help me to achieve this asap.


Hello, how to publish json message to a multiple properties on a single topic ? please help me to achieve this asap.

The mqtt extention maps mqtt topics to thing properties. After installing the extension you can choose between two different solutions for the connection and two different types of binding.


1. Use the mqtt template in a new thing and configure your broker right in the things configuration

2. Create a thing that uses mqttConnection template and configure your broker + Create a thing that inherits from mqttSubscriber and configure it to use the mqttConnection thing.


1. Automapping: Check "Enable" in automapping section. Define a topic format for the binding. Here {s} is the servername from the federation, {t} is the thingname and {p} is the property name. For example your thingname is "MyFirstMqttThing" and that one has a property named "MyProp" and you use "/tw/{t}/{p}" as format, than every new value on the property gets published to the topic /tw/MyFirstMqttThing/MyProp, every external publish to that topic is used as the new value. Automapping seems to be bidirectional!

2. manual Mapping: Add a new line to "Property to MQTT topic mappings". Set topic to a mqtt topic and name to a property name. If you check the publish check mark every change in thingworks gets published to the mqtt topic and if you check subscribe every published value on that topic gets copied to the property. Here you can bind one thing to different topic structures.


If you change something that changes subscriptions, call restartThing after that or restart tomcat. There is an initialization problem otherwise.


For a more Event driven approach simply subscribe to the data change events.


Mario Wolff

Solution Architect


exceet Secure Solutions AG

Rethelstraße 47

40237 Düsseldorf


Vorstand: Christian Methe

Aufsichtsratsvorsitzender: Wolf-Günter Freese

Amtsgericht Düsseldorf HRB: 44361


I am trying to set one sample thing with mqtt,

It connects to mosquitto and also subscribes to the topic, but I always get "Socket error on client" when mosquitto is trying to push the message to Thingworx mqtt thing.

I am using thingworx 6.5.0 on tomcat 7.

This mosquitto server works well with eclipse paho based application on the same tomcat.

Any pointers would really of a great help.

Many Thanks



I could get MQTT Thing based solution working with 2 changes.

1. Adding an auto refresh widget

2. getting the latest MQTT extension for Thingworx 6.5. The one on market place is old.

(download link worked for me was

Hope it may provide hints for others who might be facing challenge

Hi Mario,

Now I got into another problem.

After the value of a property is updated as per mqtt subscription, I want to trigger some action.

e.g. Say if temperature is above 35 degrees, I want to send an email.

I coded required snippet.

If I manually set the property of the temperature, it sends an email.

However if same property is update from mqtt, the email subscription code does run.

How can it be fixed?

Any work around/pointers?

Need help badly as I already spent couple of days, but did not get a clue.

Thanks much


Finally I got this too working.

What I learnt is we need to change the runtime permission for services those need to be executed from the snippet.

e.g. if I am using


The runtime permissions must be allowed for Thing - EmailServ1. Please refer the image below.


Very happy having completed as this was the basis of one my imp PoC.

May be these settings are available by default and it is just me who missed them.

Nevertheless if someone is stuck like me, hope this would help them.

And of course thanks for the information in above thread.

Best Regards,

Amit Teli

Has anyone been able to configure TW5 to use RabbitMQ 3.5.6?

When I try to connect to the server I get an error

=ERROR REPORT==== 9-Nov-2015::11:15:49 ===

closing AMQP connection <0.298.0> ( ->


Hi Graham,

AMQP is a different protocol than MQTT.... the log message doesn't mention anything about MQTT or related ports.

You should verify your client configuration, addresses, ports, as well as the server side that it is allowing MQTT connections.

To verify the MQTT connection, try using the HiveMQ online MQTT web-client posted above in order to be sure that your broker is visible and working on the Internet.



Can someone help me with the setup , I followed the exact steps and still it's not showing its as Connected.

What could have been wrong.

When i am testing through chrome mqttlens, its working fine. what am i doing wrong


1 - Could you check if the MQTT extension has been correctly installed.
Go to Monitor (from the composer) and choose extension item and search for MQTT extension
If something goes wrong during MQTT installation you 'll be able to find some information.

2 - What is your operating system ? and the MQTT extension release ?

Hi Frank,

I have the same issue that the MQTT extension is not able to connect to my public mosquitto server.

MQTT_spy can connect without problem.

MQTT extension is also imported fine. I could not find any errors.

Any idea what I´m missing ?

Have been able to figure out the issue.

Seems the extension on the marketplace is not working and as per the comment on other thread , need to download the below extension for which suppor tis requried.

Can someone help if the above extension is available in public domain.

Hello, In the meantime we understood that the MQTT extension was giving problems under Linux. MQTT extension on Thingworx Server running on Windows does not have any problems.

PTC offered a new MQTT extension begin of October and now the MQTT issue on Linux based Thingworx server is solved.

Solution: Use the latest MQTT extension from the marketplace.


I have put the extension in place, everything is working fine from the device To Thingworks (subscribe MQTT)

(remark from Amit Teli about system user rigth is very important and I loose some time before to understand that my problems were coming from that)

My Question : how to publish ?

I have created a property with the publish topic (auto mapped) but how to activate it  and how to publish a message ?


the solution was in the explanations and it works fine (and very simple !)

"If you check the publish check mark every change in thingworks gets published to the mqtt topic and if you check subscribe every published value on that topic gets copied to the property. Here you can bind one thing to different topic structures."


Top Tags