【问题标题】:Load test using NPM module loadtest causes server to return HTTP code 400使用 NPM 模块 loadtest 进行负载测试导致服务器返回 HTTP 代码 400
【发布时间】:2020-12-15 06:26:24
【问题描述】:

我正在尝试使用loadtest 执行负载测试。我正在尝试在 POST 参数中发送一个 JSON 对象。使用以下命令:

loadtest 'http://localhost:3000/outbreak/'
-m POST -H Content-Type:application/json -T application/json -t 2 -c 10 --rps 10
-P '{"country": "us", "state": "ma"}'

从外部loadtest 尝试时,服务器代码可以接受相同的 POST 正文并按预期工作。但是当我通过loadtest将此命令发送到服务器时,同一服务器返回HTTP状态代码400

我做错了什么?

【问题讨论】:

    标签: node.js load-testing


    【解决方案1】:

    哦,找到了解决方案。双引号需要转义!

    正确的语法:

    loadtest 'http://localhost:3000/outbreak/'
    -m POST -H Content-Type:application/json -T application/json -t 2 -c 10 --rps 10
    -P '{\"country\": \"us\", \"state\": \"ma\"}'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-10
      • 1970-01-01
      相关资源
      最近更新 更多