MQTT is simple and multiple examples can be found from forum.
MQTT was also my first Solution.
But since MQTT only communicates via Topics, I dont know how to realise the Usermanagement.
Maybe i have to combine both methods. The http Server handles the Usermanagement, while MQTT is for the devicecommunication.
Because i have to link the devices to the individual user the Topic needs a authentication part like an UUID for the User AND the Device.
Both Methods will be a hard way i think
Logic that I have used is
- New client goes online and will send it's designation to the specific room shared by all clients.
- Server app will response back to the client from room generated from client name and transfers RSA Public Key to client.
- Client will encrypt all messages with public key and send messages only to the room generated from it's own name.
I have developed multiple IoT applications and of course I'm not sure in which kind of environment your apps will run, but mine are used in extreme conditions.
If your app will work such conditions that power failure, connection loss, machine failure, machine drowning under the water and so on are weekly occurrences then check the list.
- Constantly keep everything saved on files or databases. Do not trust RAM
- Make sure your app can recover from every situation. Try Catch is your best friend
- Make sure your app can default to some settings that will work even if important databases or files are removed
- Make sure your app handles connection timeout correctly and will send message again if there is no response from server
- Make class that will log basically everything that your app does. When your app fails and it will fail, you have place where to check what went wrong.
- Make sure that your app can't be killed and it will start every time when machine starts.
- Your app must have capability to check that information saved on memory is valid and not corrupted due to power failure or such