* sleepSocketIO(long delay) halts entire io.socket thread CI #6047 Signed-off-by: lsafelix75 <lsafelix75@gmail.com>pull/13504/head
parent
3074ee3de8
commit
d2dde9768f
|
@ -24,6 +24,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
|
@ -38,6 +40,7 @@ import org.eclipse.jetty.util.URIUtil;
|
|||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.openhab.core.OpenHAB;
|
||||
import org.openhab.core.common.ThreadPoolManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -50,7 +53,6 @@ import io.socket.emitter.Emitter;
|
|||
import io.socket.engineio.client.Transport;
|
||||
import io.socket.parser.Packet;
|
||||
import io.socket.parser.Parser;
|
||||
import io.socket.thread.EventThread;
|
||||
import okhttp3.OkHttpClient.Builder;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import okhttp3.logging.HttpLoggingInterceptor.Level;
|
||||
|
@ -135,6 +137,13 @@ public class CloudClient {
|
|||
*/
|
||||
private final Backoff reconnectBackoff = new Backoff();
|
||||
|
||||
/*
|
||||
* Delay reconnect scheduler pool
|
||||
*
|
||||
*/
|
||||
protected final ScheduledExecutorService scheduler = ThreadPoolManager
|
||||
.getScheduledPool(ThreadPoolManager.THREAD_POOL_NAME_COMMON);
|
||||
|
||||
/**
|
||||
* Constructor of CloudClient
|
||||
*
|
||||
|
@ -316,8 +325,12 @@ public class CloudClient {
|
|||
logger.warn("Error connecting to the openHAB Cloud instance. Reconnecting.");
|
||||
}
|
||||
socket.close();
|
||||
sleepSocketIO(delay);
|
||||
socket.connect();
|
||||
scheduler.schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
socket.connect();
|
||||
}
|
||||
}, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
})//
|
||||
|
||||
|
@ -685,16 +698,6 @@ public class CloudClient {
|
|||
return headersJSON;
|
||||
}
|
||||
|
||||
private void sleepSocketIO(long delay) {
|
||||
EventThread.exec(() -> {
|
||||
try {
|
||||
Thread.sleep(delay);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String censored(String secret) {
|
||||
if (secret.length() < 4) {
|
||||
return "*******";
|
||||
|
|
Loading…
Reference in New Issue