5

Can we deploy a Moquette/Mosquitto broker inside Android for MQTT client communication?

I want to deploy a Moquette/Mosquitto broker inside Android and one MQTT client will communicate to another using that broker.

Magnilex
  • 11,584
  • 9
  • 62
  • 84
yuvi
  • 79
  • 8
  • For what purpose do you want to run the broker inside an Android application rather then on a server? – User404 Apr 09 '15 at 09:28
  • Actually you are right I must deploy the broker in server but....once I deploy broker inside the server than my application will IPC specific (that means I have to use the internal API for internal communication) but I wanna make my application protocol specific . – yuvi Apr 09 '15 at 12:08
  • Is it possible if yes than how ? – yuvi Apr 09 '15 at 12:10
  • 2
    Any luck with running a broker on Android? Very interested I am. – VH-NZZ Feb 04 '16 at 11:11

2 Answers2

2

Theoretical speaking, yes you can because Moquette is a java based broker, and Android uses java SDK, but practically, that should not ever be made.

You would need a mqtt client, which in your case, a Java client, such as paho client, and the broker should be running on a real server

William Kinaan
  • 28,059
  • 20
  • 85
  • 118
1

There must exist a major reason to have a Broker embedded in a mobile client an not in a server.

The rationale is that you have the broker running in a server, then several mobile clients exchange messages by publishing and subscribing to specific topics in the server broker.

For that reason mobile clients should implement MQTT clients such as Paho Android Service: https://eclipse.org/paho/clients/android/

Teixi
  • 1,077
  • 8
  • 21
  • Actually Broker is running in Server side.but if I embedded one broker in Android device so all the communication over MQTT which will save my maintenance effort. – yuvi Jul 25 '15 at 17:17
  • Mobile MQTT Client (Paho) <-----> Server MQTT Broker (Moquette) If you have an MQTT client in your mobile app, all communication will be over MQTT protocol and you can publish (send) or subscribe (receive). – Teixi Jul 27 '15 at 08:30
  • Yes I am following same approach, actually internal & as well as external communication over MQTT . if I go with this approach I can reuse most of the code for both internal & external communication – yuvi Jul 27 '15 at 12:22
  • 1
    You can try if it make sense to a) The rationale of porting effort and device resource consuming to make Moquette running as an Android Background Service in order to assure that is running all the time (even if you close the app). b) Only run the Moquette when the app is running (for inter-app communications) and for the Mobile to Server communication use the Paho Android Service MQTT Client. – Teixi Jul 27 '15 at 14:17