question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP: Handle HTTP/2 GOAWAY premature close

See original GitHub issue

The problem can be reproduced with a standard nginx version, with ssl and http/2 activated, as by default, nginx recycles http2 connection every 1000 requests

I’ve just modified the standard nginx config ( from ubuntu standard package) with http2 and ssl config:

server {
        listen 443 ssl http2 default_server;
        include snippets/snakeoil.conf;

        root /var/www/html;
        server_name localhost;
}
class BasicSimulation extends Simulation {

  val httpProtocol = http
    .baseUrl("https://localhost") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .doNotTrackHeader("1")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")
    .enableHttp2
    .disableCaching // caching disabled to reproduce the problem with static resources

   val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses
    .forever(
      exec(http("request_1")
      .get("/"))
      .pause(10 milliseconds) 
      .exitHereIfFailed
    )
  setUp(scn.inject(constantConcurrentUsers(1) during (5 minutes)).protocols(httpProtocol))
}

The reproduction of the problem depends on the pause duration, the latency between client and server and probably the load of the different systems:

  • with a remote system and a slow network, the problem can occurs sometimes with 100ms pause
  • with a local/fast server, I had to reduce the pause to 10 ms
  • On my real test, I use pace, so when the system starts to slow, I believe the pause time is reduced a lot and explain why the problem occurs

when the error occurs, the following messages can be seen:

---- Errors --------------------------------------------------------------------
i.n.h.c.h.Http2Exception$StreamException: Cannot create stream      1 (100,0%)
 2003 greater than Last-Stream-ID 2001 from GOAWAY.

and then:

i.g.h.c.i.RequestTimeoutException: Request timeout to localhos      1 (20,00%)
t/127.0.0.1:443 after 60000 ms

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
niyinsilcommented, Apr 16, 2019

Hi,

package computerdatabase

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class Http2Sample extends Simulation {

 val httpProtocol = http // 4
    .baseUrl("http://localhost:8081") // 5
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // 6
    .doNotTrackHeader("1")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0")
	.enableHttp2
    .http2PriorKnowledge(Map("www.google.com" -> true, "gatling.io" -> false))
	.disableCaching

  val scn = scenario("Http2Sample") // 7
    .exec(http("request_1") // 8
      .get("/")) // 9
    .pause(10 milliseconds) // 10
	.exitHereIfFailed

  setUp( // 11
    scn.inject(
	atOnceUsers(1)) // 12
  ).protocols(httpProtocol) // 13
}

I am also facing the same error for aforesaid code, could you please help?

Simulation computerdatabase.Http2Sample started...
11:12:12.307 [WARN ] i.g.h.e.GatlingHttpListener - Request 'request_1' failed for user 1
io.gatling.http.client.impl.HttpAppHandler$1: Premature close
11:12:12.317 [WARN ] i.g.h.e.r.DefaultStatsProcessor - Request 'request_1' failed for user 1: j.i.IOException: Premature close

================================================================================
2019-04-16 11:12:12                                           1s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=0      KO=1     )
> request_1                                                (OK=0      KO=1     )
---- Errors --------------------------------------------------------------------
> j.i.IOException: Premature close                                    1 (100.0%)

---- Http2Sample ---------------------------------------------------------------
[##########################################################################]100%
          waiting: 0      / active: 0      / done: 1
================================================================================

Simulation computerdatabase.Http2Sample completed in 0 seconds
1reaction
slandellecommented, Jul 28, 2020

Those people know who’s the best Gatling contributor, Stephane! 😄

Yeah, but then it will remain the same forever if no one else gives it a try 🤷

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle HTTP/2 GOAWAY with HttpClient?
A server is entitled to close connections at any time, for any reason. In the HTTP/2 GOAWAY frame there is the indication of...
Read more >
HTTP/2 | Node.js v19.3.0 Documentation
Once closed, http2session.destroy() might be called if there are no open Http2Stream instances. If specified, the callback function is registered as a handler...
Read more >
Update to gRPC logs GOAWAY with error code ... - GitLab
Why am I receiving a GOAWAY with error code ENHANCE_YOUR_CALM? ... but notice how the connection was closed prematurely:.
Read more >
HTTP/2 and How it Works - Carson - Medium
The stream-0 is reserved for flow-control. It cannot be closed. It is possible to prioritize streams. A server can respond with requests for...
Read more >
RFC 9113: HTTP/2 - IETF HTTP Working Group
Clients and servers MUST treat an invalid connection preface as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. A GOAWAY frame (Section 6.8)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found