Our Modbus TCP device sometimes sends MB header and MB payload in separate TCP frames. Your implementation only works when all the data is in a single TCP frame. The problem is that you don't have a real buffer but only get the data from the socket in the _onData method and expect that a full Modbus frame is present.
Adding a proper TCP buffer handling with handover of unprocessed ByteData would improve the reliability of the library a lot!
Our Modbus TCP device sometimes sends MB header and MB payload in separate TCP frames. Your implementation only works when all the data is in a single TCP frame. The problem is that you don't have a real buffer but only get the data from the socket in the _onData method and expect that a full Modbus frame is present.
Adding a proper TCP buffer handling with handover of unprocessed ByteData would improve the reliability of the library a lot!