Closed mman closed 3 days ago
@wiebeytec Working on addressing/improving/fixing the MQTT subscription logic in Venus Influx Loader: currently the code works in a way that:
onConnect
, we subscribe to 'N/+/+/#'
. I assume this is to match portalId/system/Serial
.onMessage
we check whether it's a system/0/Serial
and extract the portalId
portalId
we subscribe to N/${portalId}/+/#
)`When you say in your comment above that N/+/+/#
will be rejected, I'd like to understand how to implement the logic of extracting the portalId first and then subscribing to receive everything.
Experimenting with venus-docker
I think that:
portalId
can be replaced by directly subscribing to N/+/system/0/Serial
and parsing the reply.N/${portalId}/#
.What would be your approach? Is my assessment correct?
For your reference, the logic of first time connect to unknown portal is here:
Initial message parsing is here (note that instance number 0
was already parsed out):
And repeated connect to a known server is here:
@wiebeytec Working on addressing/improving/fixing the MQTT subscription logic in Venus Influx Loader: currently the code works in a way that:
- Immediately after MQTT
onConnect
, we subscribe to'N/+/+/#'
. I assume this is to matchportalId/system/Serial
.- Then in MQTT
onMessage
we check whether it's asystem/0/Serial
and extract theportalId
- And then once we know the
portalId
we subscribe toN/${portalId}/+/#
)`When you say in your comment above that
N/+/+/#
will be rejected, I'd like to understand how to implement the logic of extracting the portalId first and then subscribing to receive everything.Experimenting with
venus-docker
I think that:
- Detecting the
portalId
can be replaced by directly subscribing toN/+/system/0/Serial
and parsing the reply.- Receiving everything can simply be done by subscribing to
N/${portalId}/#
.What would be your approach? Is my assessment correct?
That works on LAN, but not WAN. Or at least, partly. The intracies of when it does and does not work are too subtle to fully support this, so that's why for VRM use, you need to use the VRM API to retrieve installation identifers of interest.
You then also have the MQTT server hostname available in the response. Not that calculculating it yourself doesn't work, but having one source of truth in case it ever changes in the future, may be preferable.
Quoting suggestion from @wiebeytec:
This needs to be fixed appropriately.