Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report Sender Exception hidden if another sender succeeds #947

Closed
ac87 opened this issue Nov 8, 2021 · 1 comment
Closed

Report Sender Exception hidden if another sender succeeds #947

ac87 opened this issue Nov 8, 2021 · 1 comment

Comments

@ac87
Copy link

ac87 commented Nov 8, 2021

After some time I found the bug I raised isn't specific to the HttpSender or needing to use allow cleartext, but because I had two report senders, one of which was succeeding.

When ACRA.DEV_LOGGING = true even if a sender succeeded, any ReportSenderException details for other senders should be printed to Logcat.

Everything below illustrates the difficulty I encountered because I was unfortunate enough not to be brand new to ACRA and have a sender that writes to file already.


Describe the bug
This isn't so much a bug as something that would help someone else avoid the frustration I've gone through.

I'm trying to write a simple backend server for reports, the HTTPS server isn't working correctly and to simplify things I thought I'd go back to HTTP basics with a much simpler server.

With ACRA.DEV_LOGGING = true, The debug looked as follows:

2021-11-08 10:30:52.585 12943-12971/com.test.reporting D/ACRA: Sending report using org.acra.sender.HttpSender
2021-11-08 10:30:52.585 12943-12971/com.test.reporting D/ACRA: Connect to http://192.168.1.10:9999
2021-11-08 10:30:52.628 12943-12971/com.test.reporting D/ACRA: Checking plugin Configurations : [org.acra.config.ToastConfiguration@4751f5, org.acra.config.HttpSenderConfiguration@1d4bb8a] for class : class org.acra.config.HttpSenderConfiguration
2021-11-08 10:30:52.629 12943-12971/com.test.reporting D/ACRA: Checking plugin Configuration : org.acra.config.ToastConfiguration@4751f5 against plugin class : class org.acra.config.HttpSenderConfiguration
2021-11-08 10:30:52.629 12943-12971/com.test.reporting D/ACRA: Checking plugin Configuration : org.acra.config.HttpSenderConfiguration@1d4bb8a against plugin class : class org.acra.config.HttpSenderConfiguration
2021-11-08 10:30:52.639 12943-12971/com.test.reporting D/ACRA: Sending request to http://192.168.1.10:9999
2021-11-08 10:30:52.639 12943-12971/com.test.reporting D/ACRA: Http POST content : ...
2021-11-08 10:30:52.643 12943-12971/com.test.reporting W/ACRA: ReportSenders of classes [org.acra.sender.HttpSender, ] failed, but Policy marked this task as complete. ACRA will not send this report again.

Expected behavior

If ACRA cannot connect to the server, in this case because the app wasn't allowed to use cleartext http, it should be clear in Logcat when ACRA.DEV_LOGGING = true. I assume an exception is thrown and consumed currently.

Version

  • Android 12
  • ACRA 5.8.4

Adding android:usesCleartextTraffic="true" to the application results in the following instead of the failure

2021-11-08 10:24:00.442 11441-11469/com.test.reporting D/ACRA: Request response : 200 : OK
2021-11-08 10:24:00.442 11441-11469/com.test.reporting I/ACRA: Request received by server
2021-11-08 10:24:00.444 11441-11469/com.test.reporting D/ACRA: Sent report using org.acra.sender.HttpSender

I can see the post arriving in the HTTP server so have confirmed the issue is my HTTPS server not ACRA.

@ac87
Copy link
Author

ac87 commented Nov 8, 2021

Continuing the battle with HTTPS. I finally have the root cause but only after cloning all the code and stepping though debugging.

javax.net.ssl.SSLPeerUnverifiedException: Hostname 192.168.1.10 not verified: thats what I get for trying self-signed things.

Some more feedback for the benefit of future devs.

The root cause of why I saw no exception from ACRA is because I had 2 senders, my custom one that writes to file and the new HTTP one.

You can see in my original post Sending report using org.acra.sender.HttpSender

Its from:

for (sender in reportSenders) {
try {
debug { "Sending report using " + sender.javaClass.name }
sender.send(context, errorContent, extras)
debug { "Sent report using " + sender.javaClass.name }
} catch (e: ReportSenderException) {
failedSenders.add(FailedSender(sender, e))
}
}

But the caught exception is consumed and never output if you have multiple senders, where one succeeded.

failedSenders.isEmpty() -> debug { "Report was sent by all senders" }
InstanceCreator.create(config.retryPolicyClass) { DefaultRetryPolicy() }.shouldRetrySend(reportSenders, failedSenders) -> throw ReportSenderException(
"Policy marked this task as incomplete. ACRA will try to send this report again.", failedSenders[0].exception)
else -> warn {
val builder = StringBuilder("ReportSenders of classes [")
for (failedSender in failedSenders) {
builder.append(failedSender.sender.javaClass.name)
builder.append(", ")
}
builder.append("] failed, but Policy marked this task as complete. ACRA will not send this report again.")
builder.toString()
}

failedSenders[0].exception is only output if ACRA is going to retry as per my original post: ReportSenders of classes [org.acra.sender.HttpSender, ] failed, but Policy marked this task as complete. ACRA will not send this report again.

Also

debug { "Sending request to $url" }
debug { "Http ${method.name} content : " }
debug { content.toString() }

I found this misleading, I thought this was telling me what is in content had been sent. It hasn't begun sending at this point. I spend time wireshark-ing the connecting trying to find this data, as I was seeing the handshake complete on my server. The SSLPeerUnverifiedException only occurs after the TLS handshake completes.

@ac87 ac87 changed the title HttpSender doesn't warn/error on cleartext use Report Sender Exception hidden if another sender succeeds Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant