KeenClient-Java icon indicating copy to clipboard operation
KeenClient-Java copied to clipboard

App crash if hostname blocked in host file

Open ultra-taco opened this issue 8 years ago • 2 comments

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)

ultra-taco avatar Jan 10 '17 05:01 ultra-taco

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

dkador avatar Jan 10 '17 17:01 dkador

This also happens for me. This should be fixed in the library to not allow network failures to crash apps.

eliasbagley avatar Jan 30 '17 05:01 eliasbagley