如何解决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
。
任何线索/解决方案/建议?
解决方法
检查日志。服务器发送的事件流必须具有 Content-Type
的 text/event-stream
标头,请参阅 specification。您的信息流似乎格式不正确。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。