fix: Add connection timeouts for notification handling
All checks were successful
/ build-debug (push) Successful in 5m22s
All checks were successful
/ build-debug (push) Successful in 5m22s
...and do not fail operations if notification handling fails -- notifications are best-effort.
This commit is contained in:
parent
051bb9f1e3
commit
1536343b3f
|
@ -48,11 +48,16 @@ suspend fun <T> T.beginTrackedOperation(op: suspend () -> Boolean) where T : Fra
|
||||||
Log.d(TAG, "Latest notification is $latestSeq before operation")
|
Log.d(TAG, "Latest notification is $latestSeq before operation")
|
||||||
if (op()) {
|
if (op()) {
|
||||||
Log.d(TAG, "Operation has requested notification handling")
|
Log.d(TAG, "Operation has requested notification handling")
|
||||||
// Note that the exact instance of "channel" might have changed here if reconnected;
|
try {
|
||||||
// so we MUST use the automatic getter for "channel"
|
// Note that the exact instance of "channel" might have changed here if reconnected;
|
||||||
channel.lpa.notifications.filter { it.seqNumber > latestSeq }.forEach {
|
// so we MUST use the automatic getter for "channel"
|
||||||
Log.d(TAG, "Handling notification $it")
|
channel.lpa.notifications.filter { it.seqNumber > latestSeq }.forEach {
|
||||||
channel.lpa.handleNotification(it.seqNumber)
|
Log.d(TAG, "Handling notification $it")
|
||||||
|
channel.lpa.handleNotification(it.seqNumber)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Ignore any error during notification handling
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Operation complete")
|
Log.d(TAG, "Operation complete")
|
||||||
|
|
|
@ -33,6 +33,7 @@ class HttpInterfaceImpl: HttpInterface {
|
||||||
sslContext.init(null, trustManagers, SecureRandom())
|
sslContext.init(null, trustManagers, SecureRandom())
|
||||||
|
|
||||||
val conn = parsedUrl.openConnection() as HttpsURLConnection
|
val conn = parsedUrl.openConnection() as HttpsURLConnection
|
||||||
|
conn.connectTimeout = 2000
|
||||||
conn.sslSocketFactory = sslContext.socketFactory
|
conn.sslSocketFactory = sslContext.socketFactory
|
||||||
conn.requestMethod = "POST"
|
conn.requestMethod = "POST"
|
||||||
conn.doInput = true
|
conn.doInput = true
|
||||||
|
|
Loading…
Reference in a new issue