Android Question MQTT lost connection, with good Wifi Signal

james_sgp

Active Member
Licensed User
Longtime User
Looking for advice, I`ve been trying an app using MQTT over wifi. I have a strong wifi signal all the way out at 600+m (clear line of sight), but I`m losing connection to the MQTT Broker at about 150m?
I`m sending about 10KB on data at a time, and the Broker is responding back with about 2KB of data. I`m unable to reconnect without resetting the MQTT Broker, any suggestions as to what's happening?

James
 

james_sgp

Active Member
Licensed User
Longtime User
Done some tests today, and seems to be wen the client phones screen goes black the app is not reconnecting. I can manually connect n reconnet and it works again.

Ive added some code to use Reflecrions library to keep phone awake, but isnt help.

My app is based on the MQTT with auto discovery, so am i right to say the isnt doing the connect/reconnect?

James
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Erel,

Some extra info, the client give an error ECONNREFUSED (see attached image); the only way I can clear the error and reconnect it to restart the broker and the restart the Client.
I`ve added the Connect/Reconnect code into the Client and I`m now testing.

Thanks, James
 

Attachments

  • Screenshot_20191205-221912.jpg
    Screenshot_20191205-221912.jpg
    57.1 KB · Views: 226
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Ok, i have narrowed problem down to phone sleeping, the broker always breaks connection adter 5 minutes of running. If i run the app on the phone while charging it doesnt have any problem (raun for over 7 hours).

App is using code from MQTT auto discovery so its already running as service, what else can i do to stop app from sleeping?

James
 
Last edited:
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User
I had the same problem. This solved it. Make sure you load the phone library:

Awake.KeepAlive(True)
 
Upvote 0
Top