B4A Library jMQTT - Official Android MQTT client

Attachments

  • B4A-MQTTCanvas.zip
    8.1 KB · Views: 1,509
Last edited:

sixteen

Member
Licensed User
Longtime User
Hi,Erel,Where can I download the lib? thanks a lots!

I had found it!,thanks for your works~!
 
Last edited:

coslad

Well-Known Member
Licensed User
Longtime User
So, mqtt can replace push framework!!! Good!
 

b4auser1

Well-Known Member
Licensed User
Longtime User
The canvas client works perfectly with the MQTT Broker on tcp port.
I tried to use SSL port in URI for mqtt.Initialize and got the error:
"(SocketException) java.net.SocketException: Connection reset".

How to setup mqtt client to use SSL ?
 

sarmanho

Member
Licensed User
Longtime User
Erel,
Which brokers MQTT do you recommend for thousands of simultaneous connections?
What is the best brokers MQTT?
 

Mr Mo

Member
Licensed User
Hi all,
I am just a one week newbie. My first try is working with jMQTT.
My application dialog with an Arduino broker via Wifi. The Arduino is connected by Nrf24L01 to 3 sensors.
I have no problem with subcribed message.
If I try to publish... it seem not working.
The topic is MyMQTT/21/1/V_LIGHT and the payload must be "0" or "1".
For information I have other application working with this Arduino broker.
Here is the code for publishing.
Any help welcome.

B4X:
Sub tbnLight_CheckedChange(Checked As Boolean)
    Dim msg(1) As Byte
    Select tbnLight.Checked
        Case True
            msg(0) = 0x31
        Case False
            msg(0) = 0x30
    End Select
    Log("Sent Payload: " & BytesToString(msg, 0, msg.Length, "utf8"))
    Try
        mqtt.Publish("MyMQTT/21/1/V_LIGHT",msg)
    Catch
        Log(LastException)
        If mqtt.Connected = False Then
            mqtt.Connect
        End If
    End Try
End Sub
 

TommyBee

Member
Licensed User
Longtime User
I tried to use SSL port in URI for mqtt.Initialize and got the error:
(CertificateExpiredException) java.security.cert.CertificateExpiredException

I use my own Cloudmqtt, the unsecure connection works fine, what's to do to fix that? :confused:
Thanx in advance.
 

TommyBee

Member
Licensed User
Longtime User
Yes indeed, it starts with ssl://
I use no self signed certificates, i just try to connect to ssl://m20.cloudmqtt.com:27019 then i get this error.
With tcp://m20.cloudmqtt.com:17019 it works.
 

TommyBee

Member
Licensed User
Longtime User
Hi Erel,
could you please add this Paho-Callback to the library:

deliveryComplete
void deliveryComplete(IMqttDeliveryToken token)
Called when delivery for a message has been completed, and all acknowledgments have been received. For QoS 0 messages it is called once the message has been handed to the network for delivery. For QoS 1 it is called when PUBACK is received and for QoS 2 when PUBCOMP is received. The token will be the same token as that returned when the message was published.

Think it's essentielly needed in most all cases.
Thank's in advance ;)
 

oymyakon

Member
Licensed User
Longtime User
Hi,
When i receive a payload i get [B@996b933 instead of the string i sent (20.6 C, 6.0, -57) can you help paul.
 

haungmaojung

Member
Licensed User
Longtime User
Hi Erel,
1. I found that jMQTT library did not support client to set up LWT (Last Will Testment)
2. I've setup a client (MQTT-Spy running on my NB computer) to publish message with
a last will message> Will-Topic: 'LastWill/Sensor1' Will-Payload: 'sensor lost contact'
3. Then I created a situation(unplug RJ45 cable) to simulate network error to
cause Broker to publish Last will message
4. In my B4A android device, I've subscribe this topic(modify MQTTCanvas sample)
5. When KeepAlive interval timeout, MQTTCanvas received a message callback,
but it prompts Error Occurred
---------------------------------------------------------------------
An error has occurred in sub:main_mqtt_messagearrived(java
line: 487)
java io.IOException
Continue?


I found the error line 487 in b4a java source code which is
......
//BA.debugLineNum = 83;BA.debugLine="obj = serializator.ConvertBytesToObject(Payload)";
_obj = _serializator.ConvertBytesToObject(_payload);
....

Did I miss something? Please help.

Best Regards,
Victor
 
Top