When does a http2 TCP connection close?

Sato

I understand that http2 uses one tcp connection to serve multiple requests, for example, if I request index.html which contains a.css and a.js, these three requests will be done in one tcp connection.

What happens if user clicks index2.html? does this request still use the same previous tcp connection? If so, will the browser keep the connection open until user closes the browser? And on the server side, does the server keep many connections open all the time?

sbordet

When using HTTP/2, browsers typically open only one connection per domain.

In your example, index2.html will be sent on the same TCP connection that was used for index.html, a.css and a.js.

In HTTP/2 requests are multiplexed on the same TCP connection, so that the browser can send them concurrently, without waiting for a previous request to be responded to.

Both browsers and servers have an idle timeout for TCP connections. If the connection is idle for long enough, it will be closed by either party - the one that has the shorter idle timeout, to save resources. For example, you may open a connection to a wikipedia.org, perform a few requests, and then leave that tab and work on something else. After a while (typically 30 seconds) the browser will close the TCP connection to wikipedia.org.

On the server side, the server will keep the connections from various clients open, until they are either closed by the client or until the server-side idle timeout fires, at which point it's the server that initiated the close of the TCP connection.

With HTTP/2, the number of connections that a server has to maintain is vastly less than it was with HTTP/1.1. With HTTP/2, a server has to maintain just 1 TCP connection per client; with HTTP/1.1, the server had to maintain typically 2-8 TCP connections per client.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

When does sshpass close a connection

Connection header disapper when HTTP2

Does Nginx close client TCP connection before sending back the http response?

Close TCP Connection

In Java when does a URL connection close?

when to close a socket tcp

What the half close does in http2? What the diff between local and remote in stream state in http2?

Does an open TCP socket connection consume data when not used?

when to close connection in mongodb?

Why docker close the tcp connection immediately?

RabbitMq, client close TCP connection abruptly

F# Close tcp client connection

How to stop\close\kill tcp connection on macOS

Does Websocket use the same TCP connection that was used by the initial HTTP for the handshake?

How to close an HTTP connection?

Why Akka HTTP close user connection, when multiple messages is produced?

Python3 http request close connection when nothing is sent

When should an http.RoundTripper close its connection?

Does pandas need to close connection?

Does JdbcCursorItemReader have to close connection?

Is there still a practical 6 connection limit when using Server Sent Events with HTTP2?

flask - When to close mysql connection?

How to close sql connection when using mysql2/promise?

When I try to close ssh2 connection, no response back

When is a TCP connection considered idle?

PlatformNotSupportedException when establishing a TCP connection

Does DBCP connection pool connection.close() return connection to pool

Exception: connect: does not exist (Connection refused) when trying to connect to TCP socket in Haskell

Why does my TCP connection not provide a response to a message when it works OK in netcat (nc) and telnet?