Skip to content

Commit

Permalink
Added dispose on reinit. Updated deprecated way of initializing sslco…
Browse files Browse the repository at this point in the history
…ntextfactory
  • Loading branch information
seaside1 committed Oct 4, 2023
1 parent 4b07591 commit 9884728
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private synchronized void reinit() {
reInitializationFuture = UniFiProtectUtil.delayedExecution(INITIALIZATION_DELAY_SECS, TimeUnit.SECONDS);
reInitializationFuture.thenAcceptAsync(s -> {
logger.info("Socket failed, reinitializing!");
dispose();
final boolean startStatus = start();
reInitializationFuture = null;
if (!startStatus) {
Expand Down Expand Up @@ -165,6 +166,7 @@ public synchronized void stop() {
try {
socket.removePropertyChangeListener(this);
wsClient.stop();
socket.dispose();
cancelWatchDog();
cancelReinitFuture();
socket = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public UniFiProtectEventWsClient(HttpClient httpClient, UniFiProtectJsonParser u
}

public UniFiProtectEventWebSocket start() throws IOException, Exception {
client = new WebSocketClient(new SslContextFactory(true));
final HttpClient httpClient = new HttpClient(new SslContextFactory.Client(true));
client = new WebSocketClient(httpClient);
final UniFiProtectEventWebSocket socket = new UniFiProtectEventWebSocket(uniFiProtectJsonParser);
client.start();
final URI destUri = new URI(uri);
Expand Down

0 comments on commit 9884728

Please sign in to comment.