New tutorial: https://www.b4x.com/android/forum/threads/server-conscrypt-and-http-2.93040/
B4J v4.00 adds support for Http/2. This is the new version of the Http protocol.
The two main benefits:
1. Better performance with less server overhead.
2. Optional protocol. If the browser doesn't support it then Http 1.1 will be used instead.
Note that all modern browsers support Http/2.
Adding support for Http/2 requires some configuration:
1. Configure SSL as it only works with SSL (https) connections: [Server] SSL Connections
2. Set Server.Http2Enabled to True.
3. Add the alpn boot jar to the boot class path.
You need to download and add a jar file named alpn-boot.
You can read more about this jar file (including its license) here: http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html
You need to download the correct version based on the Java version.
http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions
The jars are available here: http://search.maven.org/#search|gav|1|g:"org.mortbay.jetty.alpn" AND a:"alpn-boot"
For Java 8.65 and 8.66 you can download this jar: http://search.maven.org/remoteconte...8.1.6.v20151105/alpn-boot-8.1.6.v20151105.jar
The jar file should be copied to the Objects folder.
During development you need to use the #VirtualMachineArgs attribute to add this jar to the classpath:
Command line / terminal:
An example is attached. You will need to update the alpn version based on your Java version and run it.
It will display the protocol used. Try it with these two links:
http://127.0.0.1:51041/test (should display Http/1.1)
https://127.0.0.1:51042/test (should display Http/2)
The second one will issue a warning about the unrecognized certificate, as this is a self signed certificate.
The two main benefits:
1. Better performance with less server overhead.
2. Optional protocol. If the browser doesn't support it then Http 1.1 will be used instead.
Note that all modern browsers support Http/2.
Adding support for Http/2 requires some configuration:
1. Configure SSL as it only works with SSL (https) connections: [Server] SSL Connections
2. Set Server.Http2Enabled to True.
3. Add the alpn boot jar to the boot class path.
You need to download and add a jar file named alpn-boot.
You can read more about this jar file (including its license) here: http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html
You need to download the correct version based on the Java version.
http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions
The jars are available here: http://search.maven.org/#search|gav|1|g:"org.mortbay.jetty.alpn" AND a:"alpn-boot"
For Java 8.65 and 8.66 you can download this jar: http://search.maven.org/remoteconte...8.1.6.v20151105/alpn-boot-8.1.6.v20151105.jar
The jar file should be copied to the Objects folder.
During development you need to use the #VirtualMachineArgs attribute to add this jar to the classpath:
B4X:
#VirtualMachineArgs: -Xbootclasspath/p:alpn-boot-8.1.xxxxxxx.jar
Command line / terminal:
B4X:
java -Xbootclasspath/p:alpn-boot-8.1.4.v20150727.jar -jar <your jar>.jar
An example is attached. You will need to update the alpn version based on your Java version and run it.
It will display the protocol used. Try it with these two links:
http://127.0.0.1:51041/test (should display Http/1.1)
https://127.0.0.1:51042/test (should display Http/2)
The second one will issue a warning about the unrecognized certificate, as this is a self signed certificate.
Attachments
Last edited: