# HTTP2 not working with SSE

**URL:** <https://community.gatling.io/t/http2-not-working-with-sse/7931>\
**Category:** Gatling (Open-Source)\
**Created:** [May 9, 2023, 3:01pm UTC](https://community.gatling.io/t/http2-not-working-with-sse/7931 "2023-05-09T15:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PerfGatTester](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/perfgattester/32/1246_2.png) [@PerfGatTester](https://community.gatling.io/u/PerfGatTester)\
**Post date:** [May 9, 2023, 3:01pm UTC](https://community.gatling.io/t/http2-not-working-with-sse/7931/1 "2023-05-09T15:01:20Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [May 9, 2023, 3:20pm UTC](https://community.gatling.io/t/http2-not-working-with-sse/7931/2 "2023-05-09T15:20:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [June 8, 2023, 3:20pm UTC](https://community.gatling.io/t/http2-not-working-with-sse/7931/3 "2023-06-08T15:20:26Z")

</div>

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