Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Telit Cinterion IoT Developer Community

Paho project 1.1.0 - July 2016 - MQTT 3.1.1

Showcase, December 2, 2016 - 6:00pm, 15087 views


This showcase is a Java ME 3.2 example of the PAHO 1.1.0 project for sending MQTT 3.1.1 messages.

First, we send a typical "Hello World!" message followed, secondly by a JSON style "sensor message" with the module's PCB temperature.

MQTT is a lightweight wide-area comms protocol useful for M2M / IoT devices, that communicate via brokers, with their head-end systems or cloud services.

This release is based on the July 2016 PAHO project code. Ported to Java ME 3.2 for the Thales IoT BGS5, EHSx, ELS61, and PLS62 modules - all sources are included in the ZIP file(s) below. 

During 2018 the patched PAHO library sources were slightly "refactored" to avoid a naming conflict and a "Java error 137" on Thales IoT modules PLS62-W and ELS61 rel 2.

The distribution's .JAD file can be modified to take parameters such as broker, setAPN, setUser and setPass.
Please refer to to see what each of the does.

PAHO 1.1.0 - Getting Started Java SE sample code originally from here: (for example source code, please see bottom of that page)

In the J2ME 3.2 port of the PAHO 1.1.0 MQTT 3.1.1 (from July 2016) there are 74 original PAHO classes

Of these we had to patch 25 of them:
14/10/2016  17:32            47,823
14/10/2016  15:06            21,711
14/10/2016  11:17            21,751
14/10/2016  17:38             8,745
14/10/2016  11:44            10,503
14/10/2016  11:45             2,577
14/10/2016  12:07            27,324
14/10/2016  14:02            57,903
14/10/2016  14:03            15,907
14/10/2016  14:04             5,080
14/10/2016  14:34             8,066
14/10/2016  14:40             4,584
18/10/2016  09:04             2,095
14/10/2016  15:22             3,328
14/10/2016  15:17             3,582
18/10/2016  09:13             2,585
14/10/2016  14:58             3,121
14/10/2016  15:01             2,953
14/10/2016  17:36             6,309
14/10/2016  17:24             8,184
14/10/2016  17:07            25,966
14/10/2016  17:15             6,170
14/10/2016  17:27             3,011
14/10/2016  12:21             5,918
14/10/2016  11:42             5,649

-- end




web sockets client


See also (Java MQTT X-Nucleo)

See also: Using the new JAT (Java AT command) extension interface. The demo shows how to use our Java MQTT client via AT^SJMQTT

Netbeans 7.2 offline install:



thanks for sharing! Connecting via tcp is working fine, unfortunately I cannot connect via tls. My guess is that I need to supply the brokers certificate. Is there a way to do this with this release?

edit: I was able to import the certificate but still cannot establish an encrypted connection. Most of the time I am getting a EOFException. I am guessing, that the socket gets closed either by the client or the server. Is there any way I can verify this? 


This is only a basic demo. Also, ensure your module is using the latest firmware, for example EHSx modules need to be on at least "release 3 arn 51" firmware.

For a really good guide to using TLS security please see the related article for Amazon AWS and this MQTT library, here:

Best regards


Hello Simon,

thank you very much for posting this sample, really helpful.

I am facing two issues. One i am not able to resolve dependancy for statement


in file

second, i am blocked on what API settings or Security settings to setup on application descriptor level for Java Me project in eclipse\netbeans.

I tried socketProtocol and http protocol and both are not liking when i pass tcp address as broker.

i will really appreciate any pointers\help

Hello mangatrai

The BufferedOutputStream issue sounds like you have a too old or wrong Java SDK or Platform selected. Please read our Java Users Guide section 10 on the Java developer CDROM. Available from our extranet.

The API settings - please see this example and the .JAD file. I have enclosed an example where you can easily use the JAD file to select APNs and MQTT Broker info. Also discussed in the attached PDF file.

I do hope this helps.

Thanks so much for sharing! :)

I have a question though, I hope you can help me.

How can I change the MQTT topic and message? I've tried hardcoding it in the '' (changing the pubTopic and pubContent strings on lines 36 and 37), and then re-installing the MqttClient2016.jad MIDlet on the EHS6, but it seems to ignore my changes :S Any ideas about what I'm doing wrong?

Thanks dude!


Please see and this line:

String pubTopic = "testtopic";         // see

You would need to rebuild the JAD and JAR file, after making this change, with either Eclipse or Netbeans.

Best regards



Thanks for the library and sample.

What to do to run this application at BGS5T. Do you plan to make this update?

(For BGS5T) I can succesfully run the Jar and Jad file(in dist file) manual(run AT^SJAM=1,"a:/MqttClient2016.jad",""<cr>).

When I try to debug source codes through Eclipse, I get the following error.

Exception in thread "Object Server Connection - Handle JMX Notification Thread" java.util.ConcurrentModificationException

at java.util.ArrayList$Itr.checkForComodification(Unknown Source)

at java.util.ArrayList$ Source)

at com.sun.jme.toolkit.remoting.client.rmiimpl.ObjectServerConnectionImpl$ Source)

at Source)

But I can succesfully debug when I try to debug it for the second time.

The current status for Debug is the same in run mode (I see it as successful when I run it 2 *****).

Please see the work we have been doing with Amazon AWS and ESEYE.

The here was to offer a virtually Zero Touch experience onboarding to AWS with ESEYE SIMs.

It will work on all PLS62-W rel 1, ELS61 rel 2 and EHSx rel 4 modules.

Good Morning.

I am trying to include this MQTT library to my modem.

I tried using AT ^ SJMQTT modifying the .jad, installing and running, and the modem started to reboot constantly, so I had to freeze the execution and uninstall the application. I did the same with "MqttClient2016", it did not cause the module to restart, but it ends the execution a few seconds after starting it.

I have included the MqttClient2016.jar file as a library to my java midelt project. I make the connection with the example of the main class.

Imports did not give me a problem, but when executing the midlet, it throws me an exception in this line of code:
sampleClient.connect (connOpts);
even removing the settings leaving it like this:
sampleClient.connect ();

the exception is the following:

[Main]: MqttException system error:
reason 0
msg [] MqttException
loc [] MqttException
cause java.lang.IllegalArgumentException: BearerType Invalid
exception [] MqttException (0) - java.lang.IllegalArgumentException: BearerType Invalid

What could it be? I understand that it has to do with the parameters that I set in:
MqttClient sampleClient = new MqttClient (broker, clientId, persistence);

the broker contains the ip of my server: tcp: // ip: 1883
clientId the same as the main class, the device imei.

Thanks a lot.

I have an EHS6:

A-REVISION 00.000.51

Good morning, sorry it was my mistake, I did not pass the parameters of the sim connection well. the user, password and apn. I already connect without problem.

Thanks for the contribution from the library!


mullengers's picture