aedes icon indicating copy to clipboard operation
aedes copied to clipboard

Make tests that after connected/clientReady event.

Open gnought opened this issue 5 years ago • 26 comments

We assumed that client connection is ready when writing mqtt packets, we strengthen tests not to have race conditions.

gnought avatar Jan 24 '20 09:01 gnought

I think this depends on what we decide to do with #362

robertsLando avatar Jan 24 '20 09:01 robertsLando

@robertsLando Yes, it's inspired by #362

gnought avatar Jan 24 '20 09:01 gnought

@mcollina I have added those tests in my PR.

robertsLando avatar Jan 24 '20 13:01 robertsLando

Is this still required even if we have decided to queue incoming packets?

robertsLando avatar Jan 24 '20 13:01 robertsLando

I think we should wait to land #362

mcollina avatar Jan 27 '20 08:01 mcollina

@mcollina So what we do now with this now? Is it unecessary?

robertsLando avatar Jan 29 '20 10:01 robertsLando

This currently conflicts.

I'm not opposed to this landing.

mcollina avatar Jan 29 '20 12:01 mcollina

@mcollina CI fixed

robertsLando avatar Jan 29 '20 16:01 robertsLando

Please hold a bit, I’m going to make a big change. This PR may be closed after that if my work is successful. Btw, I prefer to use rebase rather than merge

gnought avatar Jan 29 '20 17:01 gnought

@gnought :+1:

robertsLando avatar Jan 30 '20 07:01 robertsLando

@gnought Any news about this?

robertsLando avatar Feb 05 '20 07:02 robertsLando

@robertsLando will keep you posted. my upcoming changes will be

  • replace the packet queue before connected event
  • redesign the _nextBatch

gnought avatar Feb 05 '20 09:02 gnought

The upcoming changes have been ready in my local working copy. I will submit a PR after the following PR has been merged into the main branch. https://github.com/moscajs/aedes/pull/409 https://github.com/moscajs/aedes/pull/408 https://github.com/moscajs/aedes/pull/416

The PR will be big, and simplify a lot. After I submit the PR, this PR could be closed, and I will need all your help how to deal with the protocol decoder.

gnought avatar Feb 07 '20 18:02 gnought

@robertsLando Here is an early access (https://github.com/gnought/aedes/commits/next) what my next PR will be after migrating #408, #416 and #418 into the main branch. The main changes are introducing a mqtt-stream-parser to replace the _nextBatch and _queue. However we still need a way to better work on the PROXY decoding.

gnought avatar Feb 10 '20 17:02 gnought

@gnought Did you made any performance testing?

robertsLando avatar Feb 11 '20 07:02 robertsLando

How do you handle packets while client is connecting as you removed the queueLimit? I saw you have paused client in connect handle.

robertsLando avatar Feb 11 '20 07:02 robertsLando

About PROXY decoding, the hook should be added here: https://github.com/gnought/aedes/blob/next/lib/mqtt-stream-parser.js#L19

Like we were doing in nextBatch before.

I also suggest to start adding some more comments to the code to make it more clear why we do some operations. Like I said for client pause, it could be difficult for new developers understand how the code works

robertsLando avatar Feb 11 '20 08:02 robertsLando

@robertsLando when we pause the stream, NodeJS will do buffering itself (https://nodejs.org/api/stream.html#stream_buffering), and we could still get those buffered data after resume. Constructing our own queue is a rewheel their work.

We could do some comments on coding side after we polish it. :)

gnought avatar Feb 11 '20 09:02 gnought

@gnought Interesting :) didn't know about that, and how could we handle an overflow so? Could we set a limit someway?

robertsLando avatar Feb 11 '20 10:02 robertsLando

I answer to myself: highWaterMark option is used for that. Should this become an aedes option?

Does we handle case when stream write returns false ? (stream buffer limit is reached)

robertsLando avatar Feb 11 '20 10:02 robertsLando

I the chunk content in the process function is the same as buf in nextBatch, like @robertsLando i also suppose it should take place before the parser.parse method. @gnought have you tried your aedes branch behind a proxy yet ?

getlarge avatar Feb 12 '20 07:02 getlarge

@gnought What about your next branch? Would you mind to submit a pr?

robertsLando avatar Feb 21 '20 14:02 robertsLando

Will do. Let see if I can break it in a smaller pr. and how the PROXY architecture should be

gnought avatar Feb 21 '20 18:02 gnought

@ robertsLando What I understand is pipe() will do the overflow job in a smart way. https://github.com/nodejs/node/blob/1afec971304e5c6294bbf61bddb39b55e76b4672/lib/_stream_readable.js#L702-L720

gnought avatar Feb 22 '20 20:02 gnought

@gnought I don't understand, the link you pointed me doesn't seems to handle the overflow... We should handle it

robertsLando avatar Feb 24 '20 08:02 robertsLando