我是在Gatling开始的。我有411状态,不明白为什么。
Response DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 411 Length Required
Connection: close
Date: Tue, 13 Feb 2018 16:07:51 GMT
Server: Kestrel
Content-Length: 0
19:07:53.083 [gatling-http-thread-1-2] DEBUG org.asynchttpclient.netty.channel.ChannelManager - Closing Channel [id: 0x5f14313e, L:/10.8.1.89:52767 - R:blabla.com:5000]
19:07:53.107 [gatling-http-thread-1-2] INFO io.gatling.commons.validation.package$ - Boon failed to parse into a valid AST: -1
java.lang.ArrayIndexOutOfBoundsException: -1
...
19:07:53.111 [gatling-http-thread-1-2] WARN io.gatling.http.ahc.ResponseProcessor - Request 'HTTP Request createCompany' failed: status.find.is(200), but actually found 411
19:07:53.116 [gatling-http-thread-1-2] DEBUG io.gatling.http.ahc.ResponseProcessor -
我的代码:
package load
import io.gatling.core.scenario.Simulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LoadScript extends Simulation{
val httpConf = http
.baseURL("http://blabla.com:5000")
.authorizationHeader("Bearer 35dfd7a3c46f3f0bc7a2f06929399756029f47b9cc6d193ed638aeca1306d")
.acceptHeader("application/json, text/plain,")
.acceptEncodingHeader("gzip, deflate, br")
.acceptLanguageHeader("ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7")
.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36")
val basicLoad = scenario("BASIC_LOAD").exec(BasicLoad.start)
setUp(
basicLoad.inject(rampUsers(1) over (1 minutes))
.protocols(httpConf))
}
object BasicLoad {
val start =
exec(
http("HTTP Request createCompany")
.post("/Companies/CreateCompanyAndStartTransaction")
.queryParam("inn","7733897761")
.queryParam("ogrn","5147746205041")
.check(status is 200, jsonPath("$.id").saveAs("idCompany"))
)
}
答案 0 :(得分:0)
当您不发送消息正文时,您需要添加
.header("Content-Length", "0")
作为解决方法。
我有类似的问题。我在两个环境上运行测试,不同之处在于应用程序基础结构。
测试通过了Amazon AWS,但在Azure上获得了HTTP 411。因此,问题似乎不在于加特林本身。
Gatling小组在和的聊天记录中也很好地回答了这个问题: https://groups.google.com/forum/#!topic/gatling/mAGzjzoMr1I
答案 1 :(得分:0)
我刚刚将加特林从2.3升级到3.0.2。他们编写了自己的HTTP客户端,它现在发送content-length:0,但此错误中描述的一种情况除外: https://github.com/gatling/gatling/issues/3648
因此,如果您避免将httpRequest()的方法类型作为字符串使用,例如:
exec(http("empty POST test").httpRequest("POST","https://gatling.io/"))
并按以下方式使用post():
exec(
http("HTTP Request createCompany")
.post("/Companies/CreateCompanyAndStartTransaction")...
或
exec(
http("HTTP Request createCompany")
.httpRequest(HttpMethod.POST, "/Companies/CreateCompanyAndStartTransaction")
然后将Gatling升级到3.0.2就足够了。否则,您需要等待Gatling 3.0.3