HTTP2 not working with SSE

package simulations

import io.gatling.core.Predef.*
import io.gatling.core.session
import io.gatling.http.Predef.*

import scala.language.postfixOps
import scala.util.Random

class ssetest extends Simulation {

  val httpProtocol = http.baseUrl("https://localhost:8443")
    .acceptHeader(
      "*/*"
    ) 
    .enableHttp2
    .http2PriorKnowledge(Map("localhost:8443" -> true))

  val scn = scenario("ServerSentEvents")
      .exec(
        sse("GET messages")
          .connect("/notification/events")
          .header("MemberId", session => String.valueOf(session.userId))
          .await(1)(
            sse.checkMessage("ConnectionCheck").matching(substring("connection established"))
              .check(bodyString.saveAs("InitialMessage"))
          )
      )
        .exec(
          sse("SetCheck").setCheck
            .await(20)(
              sse.checkMessage("checkMessage")
                .matching(substring("event"))
                .check(bodyString.saveAs("BODY"))
            )
        )
        .pause(30)
        .exec(sse("Close").close)


  setUp(scn.inject(rampUsers(1).during(1))).protocols(httpProtocol)

}

I am using the above code to open up SSE connections locally.

Problem Statement: HTTP/2 is not working. It always falls back to HTTP/1.1

On the other hand, if I use http.get(url) instead of sse.connect(url), it is able to establish HTTP/2 connection.

Anything I am missing here?

Indeed, Gatling’s SSE support doesn’t support HTTP/2 atm, only HTTP/1.1.

Is this something that’s critical for your organization and that you’d be willing to contribute or sponsor?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.