Dynatrace / openkit-java

OpenKit Java Reference Implementation
Apache License 2.0
35 stars 34 forks source link

OpenKit does not work on Android #203

Closed kylannjohnson closed 5 years ago

kylannjohnson commented 5 years ago

I seems like the HTTPClient implementation will not work on Android.

I get this INFO trace when trying to use the sample code in the "instrumenting your app" section of the docs

INFO  [BeaconSender] Exception occurred during connection establishment. Cause : java.net.ProtocolException: content-length promised 473 bytes, but received 295 . Retry in progress.

In HTTPClient, the Content Length used is data.length

Since this class uses java.util.zip.GZIPOutputStream, it would seem the version given in the Android framework isn't compatible.

Should it be changed to use the gzipped length?

e.g.

connection.setRequestProperty("Content-Length", String.valueOf(gzippedData.length));
stefaneberl commented 5 years ago

Hi Kylan,

thanks for bringing this to our attention and the detailed analysis. I will investigate this issue today and keep you updated.

stefaneberl commented 5 years ago

Hi Kylan,

I just wanted to let you know that the fix is already pushed to GitHub (see also https://github.com/Dynatrace/openkit-java/commit/9d018be5d5194674db40465c73d15891f17ef493) Your suggested solution

connection.setRequestProperty("Content-Length", String.valueOf(gzippedData.length));

was correct. Additionally, a test has been added to verify the HTTP header values.

A new package will be published to Bintray tomorrow and appropriate releases on GitHub will also be created.

kylannjohnson commented 5 years ago

Awesome. I'll pull it down when ready and let you know how it goes!

stefaneberl commented 5 years ago

Hi Kylan,

I wanted to inform you that the package is now available on Bintray (https://bintray.com/dynatrace/openkit/com.dynatrace.openkit/1.4.2). I've been testing it with an app on Android 8.0 and there were no logs/exceptions.

I will leave this issue open until you confirmed it works for you as well.

kylannjohnson commented 5 years ago

Looks like everything is good with 1.4.2. Thanks for the quick turn around!

stefaneberl commented 5 years ago

You are welcome! Thanks for your confirmation.