-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Use built-in async for mqtt #24786
Conversation
I should note that the default max packet size on EMQX is 1mb. So probably want to lower the default size we send to 1mb. |
I think the side effects would mainly be memory-related, i.e. buffer size both on the broker and client sides. |
With the configurable setting, and the logging on FYI, broker defaults seem to be:
|
|
||
this.client.on('message', this.onMessage); | ||
|
||
await this.onConnect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method logs logger.info('Connected to MQTT server');
while it may not be the case yet, I'm also not sure about the subscribe
before it gets connected?
* fix: Use async for mqtt. * Update mocks, fix expects * Prettier. * Use appropriate error for publish * Set max listeners immediately after connect * Add mqtt v5+ `disconnect` event handler * Set maximum packet size in `CONNECT` packet * Fix tests. * Add setting for maximum packet size. * Add `reasonString` to disconnect logs * Fix tests * Fix * Prettier
mqtt
functions, should fix some promise awaiting weirdness (also allows a nice clean up of tests...)disconnect
event (when usingversion: 5
)Also tested manually on mosquitto and nanomq on top of jest tests...
@Koenkk Some notes:
DISCONNECT
seems to not really be respected by brokers (can't get it to trigger from nanomq when exceeding maximum packet size, it just drops the packet)?disconnect
event... might not reconnect?Ref: https://www.emqx.com/en/blog/mqtt5-new-features-reason-code-and-ack
Re #24625
CC: @corporategoth @mundschenk-at
Docs Koenkk/zigbee2mqtt.io#3228