Android Question MQTT without coverage GSM only on WiFi

Lakhtin_V

Active Member
Licensed User
Longtime User
Hello, I am new MQTT technology and therefore I want to know will MQTT allow me to use Wifi for messaging? This option can to collect information from android devices near the server (broker) by WiFi? Security tools in modern versions of android will allow me to solve my problem? Where can I find an example that is tested on fresh sdk?
 

Magma

Expert
Licensed User
Longtime User
Hello, I am new MQTT technology and therefore I want to know will MQTT allow me to use Wifi for messaging? This option can to collect information from android devices near the server (broker) by WiFi? Security tools in modern versions of android will allow me to solve my problem? Where can I find an example that is tested on fresh sdk?
You can use mqtt tech with wifi for messaging between mqtt clients... you need to run your broker into the network... u can find plenty examples
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
Example MQTT chart room not worked.
https://www.b4x.com/android/forum/threads/b4x-mqtt-chat-room.61568/
Checked the example on different versions of SDK does not work. Doesn't even start
Hmmm... if you run a broker locally - be sure you have exceptions at firewall-port-and app...

then if you are sure about firewall settings at server-broker... say here... what error you did you get at logs... to help you...

if you are not sure for broker-firewall - use hivemq server-broker
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
I have an assumption that similar examples related to MQTT need to be installed on a smartphone via a USB cable, then perhaps the installation of the application will be successful. But I haven't read that advice anywhere. Maybe the B4X bridge application is conflicting with MQTT?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
I have an assumption that similar examples related to MQTT need to be installed on a smartphone via a USB cable, then perhaps the installation of the application will be successful. But I haven't read that advice anywhere. Maybe the B4X bridge application is conflicting with MQTT?
From MQTT Client there isn't any special setup to do... the only thing you must be careful is mqtt-broker/server... all other will work very easy!....

As I said you can use external-mqtt-broker for example (public hivemq...) is free
but you must set it at all clients... to test it..

then... you will find the way for setupping broker... right... simple but need some simple settings at firewall...
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
Hmmm... if you run a broker locally - be sure you have exceptions at firewall-port-and app...

then if you are sure about firewall settings at server-broker... say here... what error you did you get at logs... to help you...

if you are not sure for broker-firewall - use hivemq server-broker
When installing via USB cable, the following error occurs
B4X:
B4A Version: 11.80
Parsing code.    (0.00s)
    Java Version: 11
Building folders structure.    (0.01s)
Compiling code.    (0.01s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
Compiling resources    (0.04s)
Linking resources    (0.24s)
Compiling generated Java code.    (1.15s)
Finding libraries that need to be dexed.    (0.00s)
Dex code    (1.10s)
Dex merge    (1.54s)
Copying libraries resources    (0.44s)
ZipAlign file.    (0.03s)
Signing package file (debug key).    (0.48s)
Installing file to device.    Error
Performing Push Install
SimpleChat.apk: 1 file pushed, 0 skipped. 883.7 MB/s (1310833 bytes in 0.001s)
    pkg: /data/local/tmp/SimpleChat.apk
Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
 
Upvote 0

Magma

Expert
Licensed User
Longtime User

Uninstall previous b4xexample app from your anroid phone... and then try to install it again
 
Upvote 1

Magma

Expert
Licensed User
Longtime User
If not want to uninstall B4A Example from your phone-tablet... change the following..
B4X:
    #ApplicationLabel: B4A Example
    #VersionCode: 1

also:

from Menu, Project, Build Configurations -> Package Name...

.. but I think that will be just an example... so with an uninstall you will be ok
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
Example MQTT chart room not worked. Checked the example on different versions of SDK does not work. Doesn't even start
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Example MQTT chart room not worked. Checked the example on different versions of SDK does not work. Doesn't even start
Did you checked your smartphone, tablet... for any B4A Example APPS (installed previous)... at your phone ...Go to Settings, Applications -> remove B4A Example ...if exists, reboot phone and try to run the examples again...

Sorry I insist... may be I am wrong. But sometimes other simple things... creating problem from anywhere...

If I am wrong, tell me

ps - otherwise: describe the problem - or log you are taking...
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
Did you checked your smartphone, tablet... for any B4A Example APPS (installed previous)... at your phone ...Go to Settings, Applications -> remove B4A Example ...if exists, reboot phone and try to run the examples again...

Sorry I insist... may be I am wrong. But sometimes other simple things... creating problem from anywhere...

If I am wrong, tell me

ps - otherwise: describe the problem - or log you are taking...
I was given really good advice in the tools in the project settings to change the name of the package. Apparently when using the standard name EXAMPLE. Gradually, some kind of garbage accumulates inside the device, which prevents a new example from starting with the old name. Now all ok. The example "MQTT chat room" works on different versions of SDK and on modern smartphones too. But first I had to disable the virus scan when installing the application.
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
I am happy, you did it ! You can select the right "post" as solution - to help others too..

1675417446130.png
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
I'm sorry, but the joy was premature, now the MKTT network is not working again. I have little knowledge and I'm not sure if I have the right conditions to test the collaboration of this application on several smartphones.
1. The question is whether it is possible to debug using a Wifi router or in this case only a USB cable? My main task is to make sure everything works using WIFI direct.
2. On the smartphone, I turned on the GPS and probably somehow it is necessary to set permissions so that the mmm example works?
3. How often should the package name and program version number (Name) be changed so that a new folder with the application is formed in the device?
4. When debugging, you first need to successfully start the server on the first device, after that you can try to do debugging on the second one, which should connect as a client?
5. The example now starts the server. I'm installing the example in Release mode. Then I disconnect from the B4X bridge. Externally, the application works, prints messages, but does not see customers around and it is normal.
6. On another smartphone, I am trying to install another application. But after launching and entering a name, application does not feel the previously launched server, and prompts me to create the server again, but does not allow me to run the application in client mode.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
6. On another smartphone, I am trying to install another application. But after launching and entering a name, application does not feel the previously launched server, and prompts me to create the server again, but does not allow me to run the application in client mode.
MQTT is based on TCP/IP, it is like HTTP, it works as loog as there is a TCP/IP network, it is irrelevant to link layer.
I don't understand why you want to create the server in your app?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
I'm sorry, but the joy was premature, now the MKTT network is not working again. I have little knowledge and I'm not sure if I have the right conditions to test the collaboration of this application on several smartphones.
1. The question is whether it is possible to debug using a Wifi router or in this case only a USB cable? My main task is to make sure everything works using WIFI direct.
2. On the smartphone, I turned on the GPS and probably somehow it is necessary to set permissions so that the mmm example works?
3. How often should the package name and program version number (Name) be changed so that a new folder with the application is formed in the device?
4. When debugging, you first need to successfully start the server on the first device, after that you can try to do debugging on the second one, which should connect as a client?
5. The example now starts the server. I'm installing the example in Release mode. Then I disconnect from the B4X bridge. Externally, the application works, prints messages, but does not see customers around and it is normal.
6. On another smartphone, I am trying to install another application. But after launching and entering a name, application does not feel the previously launched server, and prompts me to create the server again, but does not allow me to run the application in client mode.
The questions you are asking are general and they re not have to do with mqtt but with way working b4a and debug...

You can search the forum for all these and you will find the right answers... sure

1. Bridge logger

2. For chat example.. I don't think need it

3.it is good uninstalling examples after using them.. general speaking

4. As I know the broker is written for b4j.. so will be better trying at windows this part of server.. but will be easier using a ready broker free from internet.. as a starter

5. . .. better use a ready broker server

6. ... hmm I think you must read general for mqtt.. try Google it mqtt protocol and differences
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
The questions you are asking are general and they re not have to do with mqtt but with way working b4a and debug...

You can search the forum for all these and you will find the right answers... sure

1. Bridge logger

2. For chat example.. I don't think need it

3.it is good uninstalling examples after using them.. general speaking

4. As I know the broker is written for b4j.. so will be better trying at windows this part of server.. but will be easier using a ready broker free from internet.. as a starter

5. . .. better use a ready broker server

6. ... hmm I think you must read general for mqtt.. try Google it mqtt protocol and differences
The example contains a broker library written for B4A. After successfully installing the application on several devices, I place them side by side. The first device where the application is launched should logically be the server(broker). All others connect to it as clients. I got this result when 4 devices were lying on the table side by side. But later I could not repeat this result and did not catch the pattern under what conditions a good result can be achieved. It is not possible to use an external server on the Internet or on a PC for my task. All my devices work in the absence of a PC and Internet access.
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
The example contains a broker library written for B4A. After successfully installing the application on several devices, I place them side by side. The first device where the application is launched should logically be the server(broker). All others connect to it as clients. I got this result when 4 devices were lying on the table side by side. But later I could not repeat this result and did not catch the pattern under what conditions a good result can be achieved. It is not possible to use an external server on the Internet or on a PC for my task. All my devices work in the absence of a PC and Internet access.
OK using b4a broker lib... not know how well is working - but i am sure will have the same results...
(at the same client-broker tablet you must use : ip address 127.0.0.1 in the ServerURI at the client that runs together with the server)

a) so... You mean the clients disconnect after some time ? what do you get at the logs...
b) ..if you lock device - not sleeping and the app is in front... they are loosing connection ?
c) I think that you are staying at the same wifi-network after connection... ? right ?
 
Upvote 0
Top