Skip to content

Difference between handleMessage and 'message' event #1810

Answered by robertsLando
cssArchitect asked this question in Q&A
Discussion options

You must be logged in to vote

I have a question about the internal TCP connection. As I see, there are two ways to handle an MQTT packet: asynchronous (default) and sequential (using handleMessage function).

Essentially handleMessage creates backpressure on stream and the other (the event) doesn't. The error you get could be due to the stream reaching its highwatermark because it's processing data too slowly in your handlePacket logic causing the read stream to be paused and then the connection is closed after a while by the broker (because of keepalive)

NodeJS reference: https://nodejs.org/en/learn/modules/backpressuring-in-streams

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by cssArchitect
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@robertsLando
Comment options

@cssArchitect
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants