From 2857440d0cffec5b81dd93b76deab4f81e32982b Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 15 Apr 2021 09:21:52 +0200 Subject: [PATCH] Fix reconnection --- .../independentnotifications/NotificationsService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/org/communiquons/comunic/independentnotifications/NotificationsService.java b/android/app/src/main/java/org/communiquons/comunic/independentnotifications/NotificationsService.java index e9d7d0c..c34af6f 100644 --- a/android/app/src/main/java/org/communiquons/comunic/independentnotifications/NotificationsService.java +++ b/android/app/src/main/java/org/communiquons/comunic/independentnotifications/NotificationsService.java @@ -150,9 +150,11 @@ public class NotificationsService extends Service implements Runnable { } + Log.v(TAG, "Wait a little before reconnecting..."); + // Wait attempting new connection // noinspection BusyWait - Thread.sleep(RECONNECT_INTERVAL * 1000); + Thread.sleep(RECONNECT_INTERVAL); } } catch (InterruptedException e) { e.printStackTrace(); @@ -176,8 +178,10 @@ public class NotificationsService extends Service implements Runnable { @Override public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) throws Exception { - Log.v(TAG, "Disconnect from independent push notifications websocket!"); - lock.notify(); + Log.v(TAG, "Disconnected from independent push notifications websocket!"); + synchronized (lock) { + lock.notify(); + } } @Override