iOS Question MQTT : Subscribe/publish topics in sequence

rabuehler

Member
Licensed User
Longtime User
Dear community,

I´m using B4i MQTTclient in conjunction with Mosquitto on Ubuntu and I get the following strange behaviour :

I publish 2 topics in sequence like this :


B4X:
..
SendMessage("All/votes/questions","hello " & DateTime.Time(DateTime.Now) )
SendMessage("All/votes/questions","hello2 " & DateTime.Time(DateTime.Now) )
..

Public Sub SendMessage( Topic As String,Body As String)
    If connected Then
        client.Publish2(Topic, CreateMessage(Body), 2, True)
    End If
End Sub

Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
    If Topic.Contains( "All/votes") Then
      ....
    end if


Everything works perfect except the arrival of the messages.

I´m expecting the event "client_MessageArrived" 2x raised, but I only get it 1x,
funnily enough the first publish ("Hello").

In the logs of the broker I can see that both messages was received and send..

btw, same behaviour with Mosquitto and with the B4J MQTT broker.

Any ideas what I´m doing wrong ?
 

rabuehler

Member
Licensed User
Longtime User
I found the (simple) solution : Delay between the sendMessages..not sure if this is a problem of my slow PC/backend or MQTT ?
 
Upvote 0
Top