Application Layer Protocol Negotiation

·

2 min read

Application Layer Protocol Negotiation

Why do we need ALPN?

When we send a request to server suppose over HTTP 2, we establish the connection with the server through the 3 way handshake in TCP extension and then the TLS protocol for secure connection of the client and server, Suppose if the server does not support HTTP 2 request it might only support HTTP/1.1; Now, in this case, we need to again send a request for TCP 3 way handshake for HTTP/1.1 and this causes addition round trips and also makes the connection inefficient; so to avoid this round trips of request the Application layer Protocol Negotiation comes in...

ALPN is a Transport layer security extension that negotiates which protocol to be performed over a secure layer in a way that avoids round trips and multiple requests.

image.png

First, the client sends TLS handshake also contains APLN extension and the list of all protocol the client supports and now the server responds with a resulting server hello from the webserver which contains the confirmed protocol to be used over the HTTP request So with Application Layer Protocol Negotiation in a layer, we can establish the connection and get merged in a layer all in just one run time.

Now you can easily send the HTTP 2 header stream it will understand it. In a way, this protocol minimizes the round trips. The negotiation is making your communication between the frontend and backend more efficient, in a way as a backend developer you don't want your client to wait and try to get back responses quickly as possible.