1

It is needed to make a HTTP2-response, which will force a client to reconnect to the same server to the same address.

In case of HTTP/1.1 it could be done sending 307 Temporary Redirect response with Connection: close header.

In HTTP/2 Connection: close header is ignored and redirect is performed without reconnection, which brings to redirect loop error.

Also, I've tried to send 421 Misdirected Request response to client with the same url, but Chrome browser is do nothing after receiving this response.

What is the most proper way to force a HTTP/2 client to reconnect? Which server response can be send? Maybe some kind of GOAWAY frame?

1
  • 2
    What's the purpose of forcing the disconnection/reconnect? Are you sure there's not an HTTP 2 solution to your problem that doesn't require tearing down the existing connection? Mar 6, 2017 at 14:46

3 Answers 3

2

Following the graceful shutdown procedure that RFC 7540 recommends should result in a reconnection:

A server that is attempting to gracefully shut down a connection SHOULD send an initial GOAWAY frame with the last stream identifier set to 2^31-1 and a NO_ERROR code. This signals to the client that a shutdown is imminent and that initiating further requests is prohibited. After allowing time for any in-flight stream creation (at least one round-trip time), the server can send another GOAWAY frame with an updated last stream identifier. This ensures that a connection can be cleanly shut down without losing requests.

Regarding 421 handling in Chrome, this bug https://bugs.chromium.org/p/chromium/issues/detail?id=546991 was opened to have Chrome re-open a new connection to the server, it's seen some activity recently.

1

Yes, the way on HTTP/2 to ask a client to reconnect for further requests is to send a GOAWAY frame to it. How this works depends on your server side implementation or framework for HTTP/2 support. E.g. a framework could intercept your Connection: close header and treat it as a request to close the connection after the request. But I guess most HTTP/2 implementations wouldn't like to do that, since they guess the header targets only the current request scope and not the whole connection. Alternatively the framework could provide a way in the request handler to not only access the request and response data but also to get a reference to the HTTP/2 connection, which can be used to send the GOAWAY.

-1

This may help you Google HTTP2

1
  • Could not find any information in the link about how a server can force client to make a reconnection.
    – DmitriyH
    Mar 6, 2017 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.