title: Jmeter protobuf testing. Could not read Protobuf message
body: <p>I am testing one project via protobuf protocol and using HTTP Request Sampler. The target appserver is also written on Java.
  There is a problem with errors in reponses: </p>
  
  <blockquote>
    <p>"Could not read Protobuf message: Protocol message contained an
    invalid tag (zero).; nested exception is
    com.google.protobuf.InvalidProtocolBufferException: Protocol message
    contained an invalid tag (zero)"</p>
  </blockquote>
  
  <p>The case is that it is happening not in 100% requests. When i used <strong>HttpClient4</strong> it was about 30-40% of failed requests. After i changed it to <strong>HttpClient3.1</strong> error rate decreased down to <strong>~10%</strong> which is also not a good deal.</p>
  
  <p>To send a protobuf message I am using variable ${data} in Bodydata tab of HttpSampler. And in BeanShell preProcessor i do the next:</p>
  
  <pre><code>(import and non-necessary stuff were ommited)
  MapViewport mv = MapRequest.MapViewport.newBuilder().setMaxX(mc.getX()+15).setMaxY(mc.getY()+15).setMinX(mc.getX()-15).setMinY(mc.getY()-15).build();
  
  byte[] data = mv.toByteArray();
  vars.put("data", new String(data));
  </code></pre>
  
  <p>Also I tryed to to use different encoding like a <strong>new String(data,"UTF-8")</strong> anso on.</p>
  
  <p>If to look on Request tab if View Result Tree I can say that all failed messages   contain "?" symbol:</p>
  
  <p><a href="https://i.stack.imgur.com/LMHPv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LMHPv.png" alt="enter image description here"></a><a href="https://i.stack.imgur.com/uAEPy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uAEPy.png" alt="enter image description here"></a></p>
  
  <p>Seems like some weird symbols should not be sent, but ~10% of requests after saving a byte array to String contain them.</p>