Previously the broker would run and compile, but would throw a runtime panic if the will was null because of GoLang's inline struct operator. Should REALLY consider adding a unit test
Created new data types to store the last time a message was received from a device along with publishing the last will topic, keepalive time, and credentials over the /connections topic. These were mirrored also over the REST API for synchronous stateful services starting up from a crashed k8s pod or other usecases. Start by subscribing to /connections/+ and then GET /api/v1/connections to get the open connections, if a device connects while you are setting up your state, your messageHandler will handle the setup since it has the same information. This information has been published over for devices you don't have any control over and for relay purposes. You can take all of the device information and now create a faux client emulating your downstream device, this may sound strange; but I have a usecase for it, a lot of cheap chinese IoT's were not designed for mass production and we have to fix their messages in the cloud before relaying them to our other legacy servers
During a temporary service re-hydration, this allows the recovering service to:
1.) Sub to /connections for all incoming connections
then
2.) Get a list of all connections that exist rn.
This is useful for rebuilding caches and if any of your edge-workers need to be restarted, they can. It also allows for you not to have a 100% coupling in Redis or any other MQ stream. There are still no routes for the MQ streams to get all conns on connect, when we migrate to this we will add in this support as well
- this race condition occurs when a client is disconnected or when hmq checks
if client still alive
Signed-off-by: Lucas Vieira <lucas.engen.cc@gmail.com>
When starting hmq immediately after booting, the IP address specified in the
--host flag (e.g. --host=10.0.0.217) might not be configured yet.
Without this commit, hmq would try to listen, give up, and then just hang.
With this commit, hmq automatically recovers.