In this post, we will list down the tasks to be done for enabling the HTTP 2.0 support in spring boot applications which are hosted in Apache tomcat webserver
Application Level Changes
Spring boot Application Configuration Changes
server.http2.enabled=true
In the spring boot application's application.properties file, we have to add the above line so that Spring boot can add the support for http2
Tomcat server configuration
In the tomcat web server, we should have SSL enabled before doing the below change.
To start with, we have to shutdown the tomcat server instance that is running
CD to the directory that has tomcat installed and cd to the bin directory and run the below command
sh shutdown.sh
We have add the UpgradeProtocol which adds the respective Http2Protocol handler classname to the connector pipeline that enables support for http2.0
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
The above UpgradeProtocol can be added to the connector as given below
<Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol"
maxThreads="150" SSLEnabled="true" ...>
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
</Connector>
The above command has omitted the SSL configuration that is present for brevity.
Once the above are done, we need to stop and start tomcat by running the below commands
1. CD to the directory that has the tomcat server's bin directory
2. Run the below command to start tomcat
sh startup.sh
Once done, navigate to the browser and open developer tools (F12 in chrome, or right click and choose "Inspect")
Navigate to the "Network" tab and view the requests that are being sent to the API Service. All of the requests should be sent using http2 identified by h2 in the protocol column.
If you are unable to find the protocol column, on the network tab header columns, right click and choose protocol
Comments
Post a Comment