protobufjs/protobuf.js

Sometimes a single message is split into two

Tutorialwork opened this issue · 0 comments

protobuf.js version: 7.2.5

I have the problem that sometimes the same object with the same code is split into two messages and then it fails because this splitting is happening.
I use on the other side Java. I'm not sure if from which side the error is caused.

socket.write(RequestObject.encodeDelimited(requst).finish());
socket.on('data', (data: Buffer) => {
    try {
        const product: Product = Product.decodeDelimited(data);
        console.log(product);
    } catch (error) {
        let completeHexString = "";
        for (let i = 0; i < data.length; i++) {
            const hexString = data[i].toString(16).padStart(2, '0');
            completeHexString += `${hexString  } `;
        }
        console.log(completeHexString);

        logger.log('warn', `Error while decoding Product: ${error.message}`);
    }
});
c1 02 0a 1f 68 74 74 70 73 3a 2f 2f 61 6d 61 7a 6f 6e 2e 64 65 2f 64 70 2f 42 30 43 48 58 35 38 50 59 5a 12 09 61 6d 61 7a 6f 6e 2e 64 65 1a 0a 42 30 43 48 58 35 38 50 59 5a 22 bb 01 41 70 70 6c 65 20 57 61 74 63 68 20 53 65 72 69 65 73 20 39 20 28 47 50 53 2c 20 34 31 20 6d 6d 29 20 53 6d 61 72 74 77 61 74 63 68 20 6d 69 74 20 41 6c 75 6d 69 6e 69 75 6d 67 65 68 c3 a4 75 73 65 20 75 6e 64 20 53 70 6f 72 74 61 72 6d 62 61 6e 64 20 53 2f 4d 20 69 6e 20 4d 69 74 74 65 72 6e 61 63 68 74 2e 20 46 69 74 6e 65 73 73 74 72 61 63 6b 65 72 2c 20 42 6c 75 74 73 61 75 65 72 73 74 6f 66 66 20 75 6e 64 20 45 4b 47 20 41 70 70 73 2c 20 41 6c 77 61 79 73 2d 4f 6e 20 52 65 74 69 6e 61 20 44 69 73 70 6c 61 79 2c 20 57 61 73 73 65 72 73 63 68 75 74 7a 2a 
warn - 16.1.2024, 20:04:31 »    Error while decoding Product: index out of range: 249 + 10 > 249
33 68 74 74 70 73 3a 2f 2f 6d 2e 6d 65 64 69 61 2d 61 6d 61 7a 6f 6e 2e 63 6f 6d 2f 69 6d 61 67 65 73 2f 49 2f 34 31 68 6e 7a 4b 6e 54 5a 6c 4c 2e 6a 70 67 32 09 34 32 33 2c 30 30 e2 82 ac 39 00 00 00 00 00 70 7a 40 40 01 
warn - 16.1.2024, 20:04:31 »    Error while decoding Product: invalid wire type 4 at offset 4