question

usernickyang avatar image
usernickyang asked ·

Questions about Managing an HTTP/2 Connection with the Alexa Voice Service

Dear Friends, I want to add avs to my android app. And after I get the login token, I find the guide says that I should use netty or jetty to managing the Http/2 connection. So is there any chances to use HttpClient or URLConnection to managing this connection or I can get some jars to use directly?
alexa voice service
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

swasey@amazon avatar image
swasey@amazon answered ·
You will not be able to use HttpClient (I assume you mean Apache's HttpClient) nor HttpURLConnection provided by Java. HttpClient won't have support for HTTP/2 until version 5.0, and HttpURLConnection in Java won't support HTTP/2 until Java 9. HttpURLConnection on Android is actually interesting because underneath it uses OkHttp, so technically it could receive HTTP/2 support whenever Google updates the underlying version of OkHttp to one that supports HTTP/2. However, on Android your best option is going to be to use OkHttp directly as a dependency in your application so that it supports as many versions of Android as possible. It supports HTTP/2 and is by far the best HTTP Client available for Android. You can find instructions on how to use it here: http://square.github.io/okhttp/ and it's pretty easy to add as a dependency to your Android project. Let us know if you need any further help!
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

usernickyang avatar image
usernickyang answered ·
I'll try to use OkHttp! Thank you!
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Will Blaschko avatar image
Will Blaschko answered ·
I'm switching over to OkHttp as well, one thing to look out for with the switch is that the new endpoint only supports certain TLS versions, so the 4.4.2 Android device I was testing on couldn't handshake, I had to switch to a 5.* device.
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

swasey@amazon avatar image
swasey@amazon answered ·
Hey Will, have you seen this: https://github.com/square/okhttp/issues/1934 , and the link mentioned within: http://blog.dev-area.net/2015/08/13/android-4-1-enable-tls-1-1-and-tls-1-2/ It looks like TLS v1.2 should be enable-able since Android 4.1. However, HTTP/2 also requires ALPN (a TLS extension for protocol negotiation) which is only supported in Android 4.4+. So, you should be able to squeeze some support out of your 4.4.2 device, but that'll be the earliest version possible.
1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Unless I'm reading the update log for OkHttp incorrectly, it looks like they removed support for HTTP/2 for older devices (the NPN version). Looks like it's a non-starter.

0 Likes 0 ·