I need some help on identifying the length of the response using the the first byte(s) of the message.
Currently using JMeter to send some TCP request but unfortunately it is not able to determine the end of the message, so it hangs.
The communication protocol is Google Protobufs (protocol buffers) and does not have an indicator to determine the end of message.
Below is what Jmeter has. I would appreciate if someone can tell me how I can build on top of this so I can measure the length of the message using the first bytes of the response.
JMETER - Read method.
public String read(InputStream is) throws ReadException {
ByteArrayOutputStream w = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[127];
int x = 0;
while ((x = is.read(buffer)) > -1) {
w.write(buffer, 0, x);
if (useEolByte && (buffer[x - 1] == eolByte)) {
break;
}
}
IOUtils.closeQuietly(w); // For completeness
final String hexString = JOrphanUtils.baToHexString(w.toByteArray());
if(log.isDebugEnabled()) {
log.debug("Read: " + w.size() + "\n" + hexString);
}
return hexString;
} catch (IOException e) {
throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
}
}