B4J Question MQTT sends my message twice

CR95

Active Member
Licensed User
I use a very simple internal MQTT broker

B4X:
Sub AppStart (Args() As String)
    lstUsers.Initialize
    brokerStarted = False

    If brokerStarted = False Then
        broker.Initialize("", port)
    
        broker.DebugLog = True   'False
        broker.Start
        brokerStarted = True
        users.Initialize
    End If
    Log("Broker started ")   ' & $"Server (${server.GetMyIP})"$)
    StartMessageLoop    ' in order to run/wait indefinitely for events
End Sub

Certainly due to a second installation or a bad usage, the broker now returns messages twice (exactly the same).
I guess that the broker library has an internal list of users and that my name is duplicated in this list ????
On the cloud, I found people having the same issue.

When I install the broker, the log indicates
Persistent store file: /home/dietpi/B4JBridge/tempjars/moquette_store.mapdbr
But this "moquette_store.mapdbr" file does not exist un my tempjars directory

A complete reinstallation of my broker does not solve the issue.

Is there a way to solve this problem ?
 

CR95

Active Member
Licensed User
No. I don't call the Broker multiple times; This is a environment that is running since several years !
Yes, QOS = 0 in my calls but I don't need the heavy process of QOS = 2.
Is there a way to "clear" the internal users table of the broker (if this is the way it works) ?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Persistent store file: /home/dietpi/B4JBridge/tempjars/moquette_store.mapdbr
1. This is just a log; this library does not generate persistent store files. It uses MemoryStorageService to save messages, and all messages will be cleared upon process restart.
2. It only supports single user authentication—I'm curious how you managed to implement multiple user authentications.
3. How did you know that MQTT sents your message twice?
4. You could try switching to the jMqttBroker2 library to see if the issue still persists.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there a way to "clear" the internal users table of the broker (if this is the way it works) ?
No and it isn't needed. The problem is somewhere else.

3. How did you know that MQTT sents your message twice?
Good question. Please provide more information.

And if there is indeed an issue then worth testing with QOS 2.
 
Upvote 0

CR95

Active Member
Licensed User
Thanks.
3. How did you know that MQTT sents your message twice

I am not certain that this is the broker which sends the message twice. I use a "spy" which listen to all the MQTT messages but it is not possible to know "who" sends a message.
I use several applications which send and receive MQTT messages and I thought that my issue (twice message) was fom the broker. As Erel said, the problem is somewhere else. I will continue to search by using the Log of the broker
 
Upvote 0

Similar Threads

  • Locked
  • Article
Android Tutorial [B4X] MQTT Chat Room
Replies
60
Views
82K
  • Locked
  • Article
B4J Library MqttBroker
Replies
51
Views
54K
  • Locked
  • Article
B4J Tutorial [IoT] MQTT Protocol
Replies
33
Views
64K
Top