KeenClient-Java
KeenClient-Java copied to clipboard
App crash if hostname blocked in host file
Keen crashes my app shortly after launch with this error.
java.lang.RuntimeException: java.net.ConnectException: failed to connect to api.keen.io/127.0.0.1 (port 443) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)
at io.keen.client.java.KeenClient.handleFailure(KeenClient.java:1617)
at io.keen.client.java.KeenClient.addEvent(KeenClient.java:166)
at io.keen.client.java.KeenClient$1.run(KeenClient.java:233)
After some digging around, I found that api.keen.io is in an ad-block hosts file commonly used with Android AdBlockers, such as AdAway. I added the hostname to the whitelist and the crash goes away, but it probably shouldn't be crashing in the first place. Not to mention the end user won't be so willing to add that to their whitelist (if they even know how to in the first place)
Sorry about the hassle. This should only be happening if you're running the client in debug mode. Can you confirm if your app is running the client in debug mode? If it is, I'd suggest turning that off for production.
Here's the relevant code: https://github.com/keenlabs/KeenClient-Java/blob/master/core/src/main/java/io/keen/client/java/KeenClient.java#L1617
This also happens for me. This should be fixed in the library to not allow network failures to crash apps.