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