You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMeter使用zalopay-grpc-request插件发起GRPC请求报错,求调试方法

问题描述

使用zalopay-oss的jmeter-grpc-request插件在JMeter中发起GRPC请求,Postman发送相同请求体可正常运行,但JMeter执行时出现解析异常错误。

错误日志

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)

JMeter结果树信息

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

响应数据错误栈

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)

求问该如何调试这个问题?


调试步骤
  • 开启插件详细日志:修改JMeter的log4j2.xml配置文件,将vn.zalopay.benchmark包的日志级别设置为DEBUG,获取解析过程中的具体错误细节,比如字段类型不匹配、格式错误等。
  • 严格校验请求体:对比Postman和JMeter的请求体,重点检查:
    • JSON格式是否完全符合GRPC proto定义,包括字段名大小写、数据类型(如数字不能加引号、布尔值需为小写true/false)。
    • 是否存在JMeter变量引用错误,比如未定义变量或变量替换后破坏JSON结构。
  • 核对proto配置:确认JMeter插件中加载的proto文件、服务名、方法名与Postman使用的完全一致,无拼写或版本差异。
  • 测试最简请求体:先构造仅含必填字段的请求体在JMeter中运行,逐步添加其他字段,定位引发解析异常的具体字段。
  • 检查环境依赖:验证JMeter使用的Java版本符合插件要求,插件jar包完整无损坏,且与JMeter版本兼容。
  • 本地调试插件源码:若以上方法无效,可下载插件源码,在IDE中对ClientCaller.buildRequestAndMetadata方法添加断点,运行JMeter调试,直接查看解析时抛出的具体异常。

内容的提问来源于stack exchange,提问作者alex_us

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 18:18:08