0

I am trying to set up a load test scenario with 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)
  
}

but it's continuously throwing error:

> 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...

Whereas, I have already tested with CURL command (and that works fine) as;

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

Now, even though, Gatling claims that Gatling automatically sets Accept header to text/event-stream and Cache-Control to no-cache., but I also tried with:

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

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

Whatever I have tried so far, the error remains the same; Server returned http response with content-type null.

Any clue/solution/suggestion?

Ahsan
  • 1
  • 6

1 Answers1

0

Check the logs. A Server Sent Event stream must have a Content-Type header of text/event-stream, see specification. It looks like your stream is malformed.

Stéphane LANDELLE
  • 6,076
  • 2
  • 10
  • 12