Closed lpatiny closed 3 years ago
I have a problem connecting to the broker
According to this , I need to be explicit about the port since MQTT.js run their WebSocket endpoints on non-standard ports.
@lpatiny Can u verify on which port we can communicate with mqtt server ?
I've tried this & it's working var client = mqtt.connect('wss://test.mosquitto.org:8081');
but for our broker is not var client = mqtt.connect('wss://mqtt.beemos.org:8081');
which means it's not running on standard ports (I have tried mqtt standard ports as well 1883, 8883)
It works on port 1883.
Just tried from my computer using
mosquitto_sub -h mqtt.beemos.org -p 1883 -t "lpatiny/Computer/server"
And I receive the correct packets: 0004E030605C24DD00220012001D6F88453500000000000D000800040000005700010010006080000000000004D2DA 0004E031605C24E300210012001D75F5342B00000000000F000900050000005500010010006080000000000004D2EE
BUT ... what I never took care of is the WebSocket story. I use the normal mqtt protocol and probably it is impossible to support it from the browser.
I'm checking this link: http://www.steves-internet-guide.com/mqtt-websockets/
The support of mqtt over websocket is not supported by default by mosquitto and it should be recompiled.
However I could not compile it on CentOS 8. I will create a new broker during the weekend based on https://github.com/moscajs/aedes
@lpatiny For now, I'm getting the data of a device only when I am on device's page (the subscription happens once we navigate to the page) But in order to have all the data history locally, the app should be listening (subscribed) to the broker permanently, should we proceed like this ? & what if we have many devices, will this be a prblm ? (receiving to much data when subscribing to multiple topics) & how much data history should we keep ? (1 day / 1 week ... )
We should answer those qsts later on. For now, I will keep things as they are by listening to the topic only on device's page (we won't get all the data history, we'll have only the received data when the page was opened)
Don't worry about the history. Some devices have memory on the board (the bioreactor has) and it can keep over 2 weeks of memory. There will be a way to catch up and ask for all the missing logs. On another topic, each device should have his own pouchdb database. Allowing to easily delete one if requires.
Based on a list of mqtt servers and topics we should create a submenu per computer.
This device is non interactive and we should 'only' listen to the packets coming from the mqtt server.
This can be tested from a command line if you are using
mosquitto
:In javascript you should use the following package: https://github.com/mqttjs to listen to the packets.
You can parse the results using: https://github.com/Hackuarium/legoino-util#parse-current-settings
You should get back a JSON with the following parameters: https://github.com/Hackuarium/legoino-device-information/blob/master/src/devices/Computer.js
Store the data should be stored in a PouchDB. The advantage of this database is that we will be able to create 'views' that allows to map / reduce and also that we can synchronise all the data in the cloud.
Display current status and plots. We should be able to select a date range.