diff --git a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt index d5050aa..34c05b2 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt @@ -19,7 +19,7 @@ class ApiService { .writeTimeout(15, TimeUnit.SECONDS) .build() private val subscriberClient = OkHttpClient.Builder() - .readTimeout(5, TimeUnit.MINUTES) // Assuming that keepalive messages are more frequent than this + .readTimeout(77, TimeUnit.SECONDS) // Assuming that keepalive messages are more frequent than this .build() private val parser = NotificationParser() diff --git a/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt b/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt index 1394c3a..033bc74 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/DownloadWorker.kt @@ -71,6 +71,7 @@ class DownloadWorker(private val context: Context, params: WorkerParameters) : W .addHeader("User-Agent", ApiService.USER_AGENT) .build() client.newCall(request).execute().use { response -> + Log.d(TAG, "Download: headers received: $response") if (!response.isSuccessful || response.body == null) { throw Exception("Unexpected response: ${response.code}") } diff --git a/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt b/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt index c58412c..3b76b9a 100644 --- a/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt +++ b/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt @@ -49,7 +49,7 @@ class WsConnection( return } if (webSocket != null) { - webSocket!!.close(1000, "") + webSocket!!.close(WS_CLOSE_NORMAL, "") } state = State.Connecting val nextId = ID.incrementAndGet() @@ -68,7 +68,7 @@ class WsConnection( } Log.d(TAG, "[$url] WebSocket(${ID.get()}): closing existing connection") state = State.Disconnected - webSocket!!.close(1000, "") + webSocket!!.close(WS_CLOSE_NORMAL, "") webSocket = null } @@ -166,6 +166,7 @@ class WsConnection( companion object { private const val TAG = "NtfyWsConnection" private const val RECONNECT_TAG = "WsReconnect" + private const val WS_CLOSE_NORMAL = 1000 private val RETRY_SECONDS = listOf(5, 10, 15, 20, 30, 45, 60, 120) private val ID = AtomicLong(0) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5222734..0978ab4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -226,6 +226,11 @@ Server URL %1$s (default) Advanced + BroadcastEnabled + Broadcast messages + Apps can receive incoming notifications as broadcasts + Apps cannot receive notifications as broadcasts + Experimental ConnectionProtocol Connection protocol Use a JSON stream over HTTP to connect to the server. This is the tried and true method, though it may consume more battery. @@ -236,10 +241,6 @@ Permanent wakelock Prevents app from sleeping to ensure timely notification delivery. This consumes a lot of battery, but some devices require this. Allows app to enter sleep mode. This may negatively impact notification delivery. It depends on the device. - BroadcastEnabled - Broadcast messages - Apps can receive incoming notifications as broadcasts - Apps cannot receive notifications as broadcasts About Version Version diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index d8c3f04..015422e 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -34,6 +34,12 @@ app:dependency="@string/settings_unified_push_enabled_key"/> + + + -