B4J Question MQTT Specific Topic

CR95

Active Member
Licensed User
For explaining my demand, I use the "chat room" example
https://www.b4x.com/android/forum/threads/b4x-mqtt-chat-room.61568/
The broker is NOT the broker of the sample but the standard broker from
https://www.b4x.com/android/forum/threads/mqttbroker.61548/
The broker runs on a Raspberry with jMQTTBroker v2 library

If I launch 2 "chat" programs on my Windows PC, they exchange correctly (messages sent on topic "all")

But if I add a Publish2 command to a specific Topic in the Send subroutine of one chat :
client.Publish2("all", CreateMessage(Body), 0, False)
client.Publish2("MySpecficTopic", CreateMessage(Body), 0, False)
the second chat reveives the message sent on "all" but it never receives the message sent on "MySpecificTopic".

Note that every chat programs have subscribed to "all/#" which means it should receive all messages.

What is wrong ?
 

CR95

Active Member
Licensed User
@EnriqueGonzalez
Thanks
With your help, I discovered that "all" is not an MQTT keyword but a simple topic !

Do you know what is the IP address that should be set in an "MQTT.Initialize" command if both client and broker are running on the same RaspBerry ?
Because I get a deconnexion when using IP = 192.168.1.etc
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You should always post a new question in a new thread.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Do you know what is the IP address that should be set in an "MQTT.Initialize"
i agree with DonManfred but to answer your question, you can use "localhost" and it should work, if you get disconnections inside the same device it means there is something wrong beside your mqtt, mqtt is very stable in that scenario
 
Upvote 0

sarmanho

Member
Licensed User
Longtime User
i agree with DonManfred but to answer your question, you can use "localhost" and it should work, if you get disconnections inside the same device it means there is something wrong beside your mqtt, mqtt is very stable in that scenario
Good morning Henry.
How do I receive the example below from you?
I looked on the website b4x.com and couldn't find it.
You can help me ?
I'm a programmer from an Amazonian city in Brazil.

My name is Alves.
I await response

 
Last edited by a moderator:
Upvote 0
Top