signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.71k stars 6.17k forks source link

Display generic "new message" notification when message download fails in background #3925

Closed 2-4601 closed 6 years ago

2-4601 commented 9 years ago

In somewhat rare cases when receiving messages in the background TS gets the GCM message but fails to download the actual message. The messages finally get retrieved when the user opens TS manually. However in these cases TS should give the user a general notification of a new message instead of failing silently.

Two example cases:

In https://github.com/WhisperSystems/TextSecure/issues/970#issuecomment-129680571 moxie wrote:

Looks like we're getting the notification, trying to retrieve the message, but the network connection is failing (even though the system reports that it is network connected). We should display a generic "you have a new message" notification after giving up. Can you open an issue specifically for that?

real-or-random commented 9 years ago

Wouldn't it be better to keep trying, maybe in larger intervals? (related to #2098)

When a notification is shown, the user will probably open TS immediately but then the connection will still fail.

2-4601 commented 9 years ago

Happened yesterday. Based on the sent time stamp I was in a basement (or just coming out) at the time when the message was sent to me. The reception in the basement is very poor (mobile network). I only received the message after opening the app 17 minutes later. Usual log: https://gist.github.com/anonymous/62289c74b825c8307f2d

2-4601 commented 9 years ago

Today a similar case as above. I was in a basement while a message was sent to me. Received it only after opening TS. This time some new exceptions in the debug log:

W/OkHttpClientWrapper( 1801): java.io.EOFException
W/OkHttpClientWrapper( 1801):   at okio.RealBufferedSource.require(RealBufferedSource.java:64)
W/OkHttpClientWrapper( 1801):   at okio.RealBufferedSource.readByte(RealBufferedSource.java:77)
W/OkHttpClientWrapper( 1801):   at com.squareup.okhttp.internal.ws.WebSocketReader.readHeader(WebSocketReader.java:130)
W/OkHttpClientWrapper( 1801):   at com.squareup.okhttp.internal.ws.WebSocketReader.readUntilNonControlFrame(WebSocketReader.java:119)
W/OkHttpClientWrapper( 1801):   at com.squareup.okhttp.internal.ws.WebSocketReader.readMessage(WebSocketReader.java:94)
W/OkHttpClientWrapper( 1801):   at com.squareup.okhttp.internal.ws.WebSocket$ReaderRunnable.execute(WebSocket.java:355)
W/OkHttpClientWrapper( 1801):   at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
W/OkHttpClientWrapper( 1801):   at java.lang.Thread.run(Thread.java:818)

And more:

W/JobConsumer( 1801): org.whispersystems.textsecure.api.push.exceptions.NonSuccessfulResponseCodeException: Unable to parse entity
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.retrieveDirectory(PushServiceSocket.java:367)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.api.TextSecureAccountManager.getContacts(TextSecureAccountManager.java:207)
W/JobConsumer( 1801):   at org.thoughtcrime.securesms.util.DirectoryHelper.refreshDirectory(DirectoryHelper.java:49)
W/JobConsumer( 1801):   at org.thoughtcrime.securesms.util.DirectoryHelper.refreshDirectory(DirectoryHelper.java:40)
W/JobConsumer( 1801):   at org.thoughtcrime.securesms.util.DirectoryHelper.refreshDirectory(DirectoryHelper.java:34)
W/JobConsumer( 1801):   at org.thoughtcrime.securesms.jobs.DirectoryRefreshJob.onRun(DirectoryRefreshJob.java:33)
W/JobConsumer( 1801):   at org.whispersystems.jobqueue.JobConsumer.runJob(JobConsumer.java:76)
W/JobConsumer( 1801):   at org.whispersystems.jobqueue.JobConsumer.run(JobConsumer.java:46)
W/JobConsumer( 1801): org.whispersystems.textsecure.api.push.exceptions.PushNetworkException: javax.net.ssl.SSLHandshakeException: Handshake failed
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.getConnection(PushServiceSocket.java:597)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.makeBaseRequest(PushServiceSocket.java:482)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.makeRequest(PushServiceSocket.java:467)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.getMessages(PushServiceSocket.java:180)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.api.TextSecureMessageReceiver.retrieveMessages(TextSecureMessageReceiver.java:139)
W/JobConsumer( 1801):   at org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob.onRun(PushNotificationReceiveJob.java:36)
W/JobConsumer( 1801):   at org.whispersystems.jobqueue.JobConsumer.runJob(JobConsumer.java:76)
W/JobConsumer( 1801):   at org.whispersystems.jobqueue.JobConsumer.run(JobConsumer.java:46)
W/JobConsumer( 1801): Caused by: javax.net.ssl.SSLHandshakeException: Handshake failed
W/JobConsumer( 1801):   at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:390)
W/JobConsumer( 1801):   at com.android.okhttp.Connection.upgradeToTls(Connection.java:201)
W/JobConsumer( 1801):   at com.android.okhttp.Connection.connect(Connection.java:155)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
W/JobConsumer( 1801):   at com.android.okhttp.internal.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)
W/JobConsumer( 1801):   at org.whispersystems.textsecure.internal.push.PushServiceSocket.getConnection(PushServiceSocket.java:586)
W/JobConsumer( 1801):   ... 7 more
W/JobConsumer( 1801): Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb7d6e7a8: Failure in SSL library, usually a protocol error
W/JobConsumer( 1801): error:1407743E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert inappropriate fallback (external/openssl/ssl/s23_clnt.c:770 0xac5c2f89:0x00000000)
W/JobConsumer( 1801):   at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
W/JobConsumer( 1801):   at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:318)
W/JobConsumer( 1801):   ... 16 more

plus the usual 100 tries. https://gist.github.com/anonymous/044dce094e6a3615ddb4

2-4601 commented 9 years ago

I tested today with these steps:

  1. Turned off wifi and enabled data on my Nexus 4
  2. Put the device in a steel pot and closed the lid
  3. Sent messages to it
  4. Waited for some time
  5. Got it out
  6. Messages arrived only after opening Signal

Log: https://gist.github.com/anonymous/add46cfe6edb7814aaee

+*********05 is the sending device. I think there's one message in the log that was sent and received before Nexus going in the pot.

2-4601 commented 9 years ago

Today I did a similar test with the pot as above: https://gist.github.com/anonymous/41bb29783a6ff49d0cd0

This time the messages did arrive without explicitly opening Signal. Just had to wait a minute or so after getting the phone out of the pot. Perhaps in my previous pot test the messages would have been downloaded without opening Signal. But for certain the situations before that (when I was in the basement) did require explicitly opening of TS.

automated-signal commented 6 years ago

GitHub Issue Cleanup: See #7598 for more information.