Question

I want to develop a simple push notification system for various android devices. After two days of documentation i've found very interesting to use MQTT protocol.

System needs: - an MQTT client on Android: eclipse Paho seems to be a good solution - any MQTT broker you like for the server part: my attention is on Mosquitto cause is Open-Source

I've read documentation and the configuration file and seemed clear. The only thing that I couldn't understand is if i can manage topics (where clients subscribe to). In particular if i can create topics and how to.

Thanks.

Was it helpful?

Solution

It's not clear whether you mean on the client side or the broker side...

Assuming you mean the broker side, you don't need to create topics, they are created automatically as needed. You can control what clients have access to what topics using the built in authentication and ACL code, or you could use an authentication and access plugin. Writing your own is quite easy, or you could use the excellent https://github.com/jpmens/mosquitto-auth-plug

On the client side, simply subscribing or publishing to a topic is sufficient to create it on the broker, assuming you have permissions for that topic. This may not be the case in all MQTT implementations.

As an example, try subscribing to the # topic on test.mosquitto.org or iot.eclipse.org. These show a huge range of available topics and there is no admin to support them in the background.

This basically means that the only administrative load you have is restricting access on the broker where required.

OTHER TIPS

Using code stole from somewhere, I made a pretty simple "MQTTMessenger" app for Android. https://bitbucket.org/mjgasner/mqttmessenger

From what I remember, you'll need to go into src/com/gasner/mqttmessenger/MessengerService.java and change the host ip to the ip of your MQTT server. For the MQTT server, I used Mossquitto server.

You'll also have to make sure you port forward port 1883 to the server.

I used this to send stock numbers to my phone. It's been almost 2 years ago, otherwise I could tell you more.

The C2DM directory is unrelated. It is Google's push notification service that I was also playing with at the time.

In the other directories at Bitbucket https://bitbucket.org/mjgasner are the .NET service and winforms app I wrote to communicate with the MQTT server. The service would accept the message from the android app through the server and reply with the stock amount it pulled from google's api.

If you have any more questions, comment below.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top