[mqtt] Reuse connections #448
Labels
No labels
architecture
authentication
backend
bug
ci/cd
cleanup
documentation
duplicate
enhancement
good first issue
help wanted
in progress
invalid
media
mobile
new feature
notes
packaging
question
ui
upstream breaking change
voice
waiting user input
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
platypush/platypush#448
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As of now integrations like
zigbee.mqttandzwave.mqttthat extend theMqttPluginand do a lot of publish+subscribe cycles are subject to big reconnection overheads - the current implementation ofmqtt.publishcloses the client after the response has been received.If I have to query the state of many devices on a Zigbee or Z-Wave network, this can mean dozens of reconnections in a short time span.
A better implementation should:
Retain an MQTT connection open on the
MqttPluginlevel, on a<host>:<port>basis.Add new subscriptions to the existing connection when needed.
Internally dispatch calls to
on_messageto the right subscription(s) on a topic basis.Close the connection only when the plugin is stopped or when the last topic is unsubscribed - and only after a given
keepalivetime.