Difference between handleMessage
and 'message'
event
#1810
-
Hello! I have a question about the internal I'm using this client library with the EMQX broker. In the first case, when I don't override the So, I overridden the As far as I know this repository, there is no difference between the
Is this the correct understanding, or am I missing something? Thank you in advance for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Essentially NodeJS reference: https://nodejs.org/en/learn/modules/backpressuring-in-streams |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply @robertsLando! Yes, you are right about the slow data processing. You have now clarified my question when you pointed out Anyway, it is now clear that because of this behaviour I need to go back to the previous implementation without Thank you again for your answer! |
Beta Was this translation helpful? Give feedback.
-
And just out of curiosity, @robertsLando I've checked the Node.js documentation about stream buffering and found that in the
But maybe there is something similar for read streams, though I haven't experienced a lot of memory consumption. This loses part of the reason for stopping read consumption (since the data is actually read into the internal buffer) and the subsequent timeout call. |
Beta Was this translation helpful? Give feedback.
Essentially
handleMessage
creates backpressure on stream and the other (the event) doesn't. The error you get could be due to the stream reaching itshighwatermark
because it's processing data too slowly in yourhandlePacket
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