B4J Library MQTT - MQ Telemetry Transport for B4J

Similar threads

B4J Tutorial [IoT] MQTT Protocol
B4A Tutorial [B4X] MQTT Chat Room
B4J Library MqttBroker
B4A Tutorial [B4X] MQTT - Connect & Reconnect
B4J Library jMQTT - Official MQTT client

Alberto Iglesias

Well-Known Member
Licensed User

This library was made based on MQTT Protocol

Installation instructions:

- Copy the .xml and .jar(s) files to your custom libraries folder

Version history:
V1.0 (First public release - Donationware):
- Initial version

Alberto Iglesias - alberto@visualnet.inf.br
Version: 1.01
  • MQTT
    • connectionlost ( As )
    • deliverycomplete (Token As String)
    • messageArrived (Topic As String, Message As String)
    • onConnect (Status as boolean As )
    • onDisconnect (Status as boolean As )
    • onInitialized ( As )
    • CleanSession As Boolean
    • KeepAliveInterval As Int
    • QoS_AtLeastOnce As Int
    • QoS_AtMostOnce As Int
    • QoS_ExactlyOnce As Int
    • generatedClientId As String
    • About As String
    • Connect (broker As String, ClientID As String, Username As String, Password As String) As Boolean
    • Disconnect As Boolean
    • Initialize (eventname As String)
    • Publish (Topic As String, Message As String, Qos As Int, Retained As Boolean)
    • Subscribe (Topic As String)
    • Unsubscribe (Topic As String)
    • Version As String
    • isConnected As Boolean

How works the MQTT protocol

Communication Infrastructure

Mosquitto Broker: http://mosquitto.org/

* This version is fully functional, the only one difference is when publishing a message the text "Donationware" is delivery with your message.
Please consider a simple €10 donation and I send to you the Library without "Donationware" text in a publish method.

Already available in B4A too:

Already available in B4i too:

Works on MAC

Works on Windows


Last edited:


Licensed User
Hi,Alberto! I try MQTT Sample for B4J. If I run in IDE work OK. If I run java - jar MqttB4J.jar
objMqtt_messageArrived not work :( (Library 1.00)


Well-Known Member
Licensed User
@Alberto Iglesias
I just purchased this lib. I see that it is not the same as the b4a lib.can you upgrade this to the same version as b4a?



Well-Known Member
Licensed User
Hi Alberto.

None of these features are in the b4j version. Can we get them into the b4j version?

V1.0.4 (Release - Donationware):
- Implement method to subscribe a topic with QoS

V1.0.5 (Release - Donationware):
- Now can be used isConnected method "BEFORE" the first connection
Last edited:


Well-Known Member
Licensed User
I did notice that the version number still says 1.0.1
But the new methods are there.

Thanks again!!!!


Active Member
Licensed User
But, can i upload to host service free? or is for install in a local machine then access with a noip program? I need remote access to a arduino device
through message text.

Pero puedo subirlo a un servicio de host gratuito (preferiría subirlo que usar uno de acceso público) o tengo que instalarlo en la computadora local y luego acceder con un programa como noip? Básicamente quiero crear un broker para un arduino y acceder remotamente enviándole mensajes.



Active Member
Licensed User
Thank's for your interest, I have searching for information about this protocol, and I think, I going to give a try to the raspberry. Do you know if exist a serious security problem?

Gracias por el interés, He estado buscando información de este protocolo y creo que probaré el raspberry. ¿Sabes si existe algún problema serio de seguridad?


Active Member
Licensed User
In this moment i can say in Raspberry 2 works, I don't think was so easy, thank you for the lib. I will recharge my paypal account and buy you a coffee. BTW, is 10 EU for each lib right?


En este momento te puedo confirmar que en el Raspberry 2 funciona perfectamente, no pensé fuera tan fácil, gracias por la librería, recargaré mi cuenta de paypal para invitarte un café. Por cierto, ¿son 10 euros por cada librería, cierto?

Last edited:


Active Member
Licensed User
BTW when I run the example code, the logs showme a message (red color), what's mean?

Por cierto al ejecutar el ejemplo me aparece el siguiente aviso (color rojo) que significa?