Conversation
|
@centurysys, could you please take a look at this PR and share your thoughts? |
|
Hi @python36, thanks for the update and for incorporating the partial read fix! The approach with looping recvInto to ensure the exact number of bytes looks correct to me, and it should address the protocol desynchronization issue we were seeing. I also think keeping pkt as a plain object (instead of moving it to a ref) makes sense, especially from a memory and GC pressure perspective. One thing I’d like to confirm is how this behaves in edge cases:
As long as those cases are handled cleanly, this looks like a solid improvement. I'll also try this in my environment (low-performance embedded system) and report back if I see anything unexpected. |
|
@python36, @ThomasTJdev, @zevv |
|
Hi @centurysys, thanks for the feedback! |
|
Hi @python36, thanks for the clarification. Yes, that behavior makes sense to me. One small point: it might be useful to distinguish between "remote closed" and other read errors in the log message, as that could help with debugging. Regarding testing: unfortunately, the original project where I encountered this issue has already been completed, and I no longer have access to the same IoT Hub environment. So it may be difficult to reproduce long-running tests under exactly the same conditions. That said, I will still try to test it in a similar setup if possible and let you know if I observe anything unexpected. |
This PR introduces a while loop for recvInto to ensure the exact number of bytes is received. This prevents protocol desynchronization caused by partial reads.
Credits: This implementation is based on the code from PR #48 by @centurysys, with some slight modifications and refactoring. Huge thanks to him for identifying this critical issue and providing the initial solution!