Skip to content
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

Optimize Connect handler #301

Merged
merged 11 commits into from
Aug 23, 2019

Conversation

gnought
Copy link
Collaborator

@gnought gnought commented Aug 13, 2019

  • For 06fc839, raise an "invalid protocol" callback error if there is

  • aedes unsupported mqtt version: CONNACK return Code = 1

  • client id length > 23 [MQTT 3.1.0 only]: CONNACK return Code = 2

  • Added preConnect handler in handleConnect between earliest connect checks and normal checks. This is useful for users if they want to do some earilest DDoS check before server send any responses back, in this phrase connected=false

  • Emit connackSent event and set connactSent=true if CONNACK is sent, not only after client event but also when normal connect checks phrase if necessary

  • Added packet arguments in connackSent event

  • not use uuid(), set clientID to 'aedes_' + shortid() if empty [MQTT 3.1.1], it is better to keep it within 23 chars for better compatibility

  • Emit clientReady event after we send back all offline messages to client, for issue Duplicate PUBLISH packets in directly push to a QoS 2 client. #281

  • Optimize negate function

  • Optimize doConnack function and we could re-use it

  • Set keepalive after authentication, save some resources if there are plenty of failed authentication

  • Clear connect timer earliest in handleConnect before preConnect, performance-wise & memory-wise if there is DDoS

- For moscajs@06fc839, raise an "invalid protocol" callback error if there is

- aedes unsupported mqtt version: CONNACK return Code = 1
- client id length > 23 [MQTT 3.1.0 only]: CONNACK return Code = 2

- Added preConnect handler in handleConnect between earliest connect checks and normal checks. This is useful for users if they want to do some earilest DDoS check before server send any responses back, in this phrase connected=false

- Emit `connackSent` event and set connactSent=true if CONNACK is sent, not only after `client` event but also when normal connect checks phrase if necessary

- Added packet arguments in `connackSent` event

- set clientID to 'aedes_' + shortid() if empty [MQTT 3.1.1], it is better to keep it within 23 chars for better compatibility

- Emit `clientReady` event after we send back all offline messages to client

- Optimize negate function

- Optimize doConnack function and we could re-use it

- Set keepalive after authentication, save some resoures if there are plenty of failed authentication
Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add the docs for preConnect?

lib/handlers/connect.js Outdated Show resolved Hide resolved
lib/handlers/connect.js Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit 1a87b45 into moscajs:master Aug 23, 2019
@gnought gnought deleted the feature/optimize_connect_handler branch August 24, 2019 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants