Sse 流崩溃 io.gatling.http.action.sse.SseInvalidContentTypeException:服务器返回内容类型为 null 的 http 响应

问题描述

我正在尝试使用 Gatling 设置负载测试场景;

package mypackage

import io.gatling.core.scenario.Simulation
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration.DurationInt

class My_LoadTest extends Simulation {
  
  val httpProtocol = http
    .baseUrl("https://my-base.url")
    .header("API_KEY","my-api-key")

  val scn = scenario("MyTestScenario")
    .exec(
      sse("mySSE").connect("/my/end-point")
        .await(10.seconds)(
          sse.checkMessage("data").check(regex("""event: snapshot(.*)"""))
        )
    )
    .pause(5)
    .exec(sse("Close").close)

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

但它不断抛出错误:

> i.g.h.a.s.SseInvalidContentTypeException: Server returned http      1 (50.00%)
 response with content-type null
> Close: Client issued close order but SSE stream was already cr      1 (50.00%)
ashed: i.g.h.a.s.SseInvalidContentTypeException: Server return...

然而,我已经用 CURL 命令进行了测试(并且工作正常)作为;

curl 'https://my-base.url/my/end-point' \
 -H 'authority: xyz’ \
 -H 'accept: text/event-stream' \
 -H 'API_KEY: my’-api-key \

现在,尽管 Gatling 声称 Gatling automatically sets Accept header to text/event-stream and Cache-Control to no-cache.,但我也尝试过:

val sentHeaders = Map("Content-Type" -> "text/event-stream","API_KEY" -> "my-api-key")

  val httpProtocol = http
    .baseUrl("https://my-base.url")
    .headers(sentHeaders)

到目前为止,无论我尝试过什么,错误都是一样的; Server returned http response with content-type null

任何线索/解决方案/建议?

解决方法

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

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

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