Android SDK and onpremise

Hi all,

We’ve been having issues with getting the Android SDK to send events to an on-premise setup.

I created a brand new Kotlin android application and followed the instructions here:

I was able to send events to sentry.io cloud platform with no problems. I then setup a brand new on-premise setup locally (20.10.1) and I could not get android events to show up. The logs showed no connection attempt which is making me think that theres an issue with the android sdk connecting to non-cloud DSNs. To confirm my on-premise setup I whipped up a new flask application and was able to send a sentry event through that.

Please help, losing hair over this!

All the best,
Riz

+1. I’m also experiencing this strange behaviour. Why does my iOS app work fine but my Android app fail with an on-premise setup?

+1
We are also in the same boat. Able to send events from iOS application however android fails.The error in my logs looks like:
E/Sentry: Envelope submission failed

We updated our server to the latest version i.e 20.10.1
It works for on-cloud but fails for on-premise.

Could you be using HTTPS with on-premise and having issues with certificate verification?

Negative, on-premise is using HTTP and am able to get events to it using Flask.

try to add

android:usesCleartextTraffic="true"

to AndroidManifest.xml to connect to on-premise with HTTP connection?

Hi @liangrong thanks for the reply. Unfortunately adding that option to androidmanifest did not help.

Just to note, my on-premise local is using HTTP and my on-premise remote is using HTTPS and I’m unable to send an event to either.

I AM able to send an event to Sentry cloud, and I AM able to send events to on-premise when using a different SDK (Flask/Python).

try to set in AndroidManifext.xml

<meta-data android:name="io.sentry.debug" android:value="true" />

and then to check the log, to see if anything is wrong.

D/Sentry: Adding Envelope to offline storage: /data/user/0/com.example.sentrytest/cache/sentry/9fd61b7b-cf94-47b8-a094-69b86f58d176.envelope
I/Sentry: No permission (ACCESS_NETWORK_STATE) to check network status.
D/Sentry: io.sentry.hints.SessionStartHint is not Retryable
E/Sentry: Envelope submission failed
java.lang.IllegalStateException: Sending the event failed.
    at io.sentry.transport.AsyncConnection$EnvelopeSender.flush(AsyncConnection.java:258)
    at io.sentry.transport.AsyncConnection$EnvelopeSender.run(AsyncConnection.java:212)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:923)
 Caused by: java.net.ConnectException: Failed to connect to /0.0.0.0:9000
    at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:147)
    at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
    at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
    at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
    at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
    at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
    at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
    at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
    at io.sentry.transport.HttpTransport.createConnection(HttpTransport.java:245)
    at io.sentry.transport.HttpTransport.send(HttpTransport.java:251)
    at io.sentry.transport.AsyncConnection$EnvelopeSender.flush(AsyncConnection.java:239)
    at io.sentry.transport.AsyncConnection$EnvelopeSender.run(AsyncConnection.java:212) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
    at java.lang.Thread.run(Thread.java:923)

Failed to connect to /0.0.0.0:9000 looks kind of fishy to me. Shouldn’t it be http://?

This is my meta data for reference:
<meta-data android:name="io.sentry.dsn" android:value="http://[REDACTED]@0.0.0.0:9000/1" />

Sentry if it would help I’d be willing to send my complete android application to you so that you can run it locally. It is a simple default application with absolutely nothing in it (and thus is easily replicable).

I guess 0.0.0.0 is a broadcast intranet address, not assigned to any particular server. It is an invalid address. You should use a valid ip address, such as 127.0.0.1 for your local server.

Switched over to 127.0.0.1 and same issue. Remember I am also having issues connecting to an https:// remote on-premise as well.

D/Sentry: Adding Envelope to offline storage: /data/user/0/com.example.sentrytest/cache/sentry/37a18d81-4718-40ff-beba-ac8996258d19.envelope
I/Sentry: No permission (ACCESS_NETWORK_STATE) to check network status.
D/Sentry: io.sentry.hints.SessionStartHint is not Retryable
E/Sentry: Envelope submission failed
    java.lang.IllegalStateException: Sending the event failed.
        at io.sentry.transport.AsyncConnection$EnvelopeSender.flush(AsyncConnection.java:258)
        at io.sentry.transport.AsyncConnection$EnvelopeSender.run(AsyncConnection.java:212)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.net.ConnectException: Failed to connect to /127.0.0.1:9000
        at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:147)
        at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)
        at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)
        at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)
        at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
        at io.sentry.transport.HttpTransport.createConnection(HttpTransport.java:245)
        at io.sentry.transport.HttpTransport.send(HttpTransport.java:251)
        at io.sentry.transport.AsyncConnection$EnvelopeSender.flush(AsyncConnection.java:239)
        at io.sentry.transport.AsyncConnection$EnvelopeSender.run(AsyncConnection.java:212) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923)

@sayeghr your DSN looks invalid to me. It should never be 0.0.0.0 or 127.0.0.1 as the former one is not even a valid IP address and the latter will always point to the local host, requiring the Sentry server to be running on the very same machine that your application is running (strongly recommend against doing this).

My guess is your system.url-prefix setting is not correct, hence you are seeing/getting incorrect DSN values from your Sentry instance. You can read more about this here: https://develop.sentry.dev/config/#general

Hey BYK,

I’m running a local sentry server on my local machine to reproduce this issue. This local setup works when I test against a flask/python setup. I strongly believe there is an issue with the latest Android SDK when connecting to onpremise sentry setups as Im having issues as follows:

  1. Cannot send events to a local on-premise setup (0.0.0.0, 127.0.0.1)
  2. Cannot send events to a remote on-premise setup, (https://sentry.[mydomain].com)

These issues are not there for Python Flask SDK and Python Django SDK, or iOS SDK (see other commenters above).

Im guessing the Android SDK developers on the Sentry team do not test against a local on-premise but are connecting to a development cloud setup and thats why they arent running into the issue?

Sorry if I sound frustrated but this issue could be replicated on your end by simply creating a new default android application and pointing it to a default sentry on-premise (20.10.1)

Alright then I’ll be looping in @bruno-garcia, one of our Android experts :slightly_smiling_face:

No need to be sorry, I’d be frustrated if I were you too! The reason is most of the time these issues turn out to be configuration issues on the operator’s end. This indeed sounds like something to do with the Android SDK but we may still be missing something. Let’s see what @bruno-garcia says.

Thanks for raising this up.

  1. Cannot send events to a local on-premise setup (0.0.0.0, 127.0.0.1)
 Caused by: java.net.ConnectException: Failed to connect to /127.0.0.1:9000

This really wouldn’t work because the loopback on Android is the actual device (or emulator).

  1. Cannot send events to a remote on-premise setup, (https://sentry.[mydomain].com)

Let’s focus on this one as it seems to be an issue.

Could you please share the logs as you did above but not with 127, or 0.0.0.0 but the actual:

https://domain based DSN?

Also, what SDK version are you trying? If the latest 3.x, does it work with say, latest 2.x?

I guess 0.0.0.0 is a broadcast intranet address, not assigned to any particular server. It is an invalid address. You should use a valid ip address, such as 127.0.0.1 for your local server.

well, firstly, a valid server address can not be 0.0.0.0, which is reserved and of broadcast usage.
secondly, 127.0.0.1 is also a reserved local loop-back address, used to access the local server only.

You need to set DSN using the valid address of your server, on whom on-premise is installed. while local server address 127.0.0.1 may work for other integration, while for android, who is in certain way a linux server, will treat this 127.0.0.1 as its own android device instead of your on-premise server.

So please use ifconfig on linux, or ipconfig on windows, or other similar to get the real IP address, and update your DNS setting accordingly.

Hi there,

When I used my local ip address (e.g. 192.168.13.7) I was actually able to send an event to onpremise sentry. I’m still having problems sending to an onpremise sentry hosted over https.

@liangrong @bruno-garcia Hey team, I noticed theres a newer version of the android SDK (3.2.0), after upgrading to 3.2.0 in my test repository I was able to send events to my HTTPS hosted on-premise. There is definitely something funky going on in 3.1.0 thats resolved in 3.2.0. Just a heads up!