无法在 Gatling 中发送 http/2 请求

问题描述

在尝试发送 http/2 请求时,我在使用 gatling 工具时遇到问题。

我在协议设置中启用了 http/2 设置,甚至添加了映射以确保客户端将使用 http2 与服务器通信,但仍然使用 http/1.1 发送请求。

在控制台输出中,您将看到服务器可以使用 http2 进行通信,但由于某种原因,请求仅使用 http 1.1 发送。

所有标题都是根据浏览器的标题编写的。

有人可以帮我解决这个问题吗?

cmd.exe

在控制台中我看到下一个:

package test

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class RecordedSimulation extends Simulation {

    val httpProtocol = http
        .baseUrl("https://sitename")
        .inferHtmlResources(BlackList(""".*\.js""",""".*\.css""",""".*\.gif""",""".*\.jpeg""",""".*\.jpg""",""".*\.ico""",""".*\.woff""",""".*\.woff2""",""".*\.(t|o)tf""",""".*\.png""",""".*detectportal\.firefox\.com.*"""),WhiteList())
        .acceptHeader("*/*")
        .acceptEncodingHeader("gzip,deflate")
        .acceptLanguageHeader("en-US,en;q=0.5")
        .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0")
            .enableHttp2
        .http2PriorKnowledge(Map("sitename" -> true))
        .disableCaching
      .disableWarmUp

    val headers_0 = Map(
        "Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Cache-Control" -> "max-age=0","sec-fetch-dest" -> "document","sec-fetch-mode" -> "navigate","sec-fetch-site" -> "none","sec-fetch-user" -> "?1","Upgrade-Insecure-Requests" -> "1")



    val scn = scenario("RecordedSimulation")
        .exec(http("request_0")
            .get("/auth?r=%2F&m=NOT_AUTHENTICATED")
            .headers(headers_0))
        .pause(2)

    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)