jmetergrpc

Gor error in Jmeter GRPC request. Cant debug it


I send GRPC request throw the Jmeter (using this library - https://github.com/zalopay-oss/jmeter-grpc-request). When i am sending request body throw the postman - al working correct When i am sending request with Jmeter - i getting error :

2024-05-03 13:10:54,009 ERROR v.z.b.GRPCSampler: java.lang.RuntimeException: Caught exception while parsing request for rpc
    at vn.zalopay.benchmark.core.ClientCaller.buildRequestAndMetadata(ClientCaller.java:187)
    at vn.zalopay.benchmark.GRPCSampler.initGrpcInCurrentThread(GRPCSampler.java:204)
    at vn.zalopay.benchmark.GRPCSampler.initGrpcRequestSampler(GRPCSampler.java:133)
    at vn.zalopay.benchmark.GRPCSampler.sample(GRPCSampler.java:90)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268)
    at java.lang.Thread.run(null:-1)

In View Results Tree i have :

Thread Name:Thread Group 1-1
Sample Start:1970-01-01 03:00:00 MSK
Load time:0
Connect Time:0
Latency:0
Size in bytes:744
Sent bytes:0
Headers size in bytes:0
Body size in bytes:744
Sample Count:1
Error Count:1
Data type ("text"|"bin"|""):text
Response code: 400
Response message: GRPCSampler parsing exception: An unknown exception occurred before the GRPC request was initiated, See response body for the stack trace.


SampleResult fields:
ContentType: 
DataEncoding: UTF-8

In response data in Tree i have :

java.lang.RuntimeException: Caught exception while parsing request for rpc
    at vn.zalopay.benchmark.core.ClientCaller.buildRequestAndMetadata(ClientCaller.java:187)
    at vn.zalopay.benchmark.GRPCSampler.initGrpcInCurrentThread(GRPCSampler.java:204)
    at vn.zalopay.benchmark.GRPCSampler.initGrpcRequestSampler(GRPCSampler.java:133)
    at vn.zalopay.benchmark.GRPCSampler.sample(GRPCSampler.java:90)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:651)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:570)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268)
    at java.lang.Thread.run(null:-1)

I dont understand reasons , so how can i debug it?


Solution

    1. Get a Java IDE

    2. Get source code for the plugin you're using from https://github.com/zalopay-oss/jmeter-grpc-request

    3. Import the project into IDE

    4. Add run/debug configuration for remote debugging on the local machine

    5. Run your JMeter instance as

      java -jar --agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 ApacheJMeter.jar
      
    6. Add breakpoint at the beginning of ClientCaller.buildRequestAndMetadata() function

    7. Walk through the function (step into) and see where and why exactly it fails

    More information: How to Debug JMeter Test Scripts