diff --git a/src/driver/src/main/java/com/edgedb/driver/binary/duplexers/ChannelDuplexer.java b/src/driver/src/main/java/com/edgedb/driver/binary/duplexers/ChannelDuplexer.java index 2ff86af..9631f78 100644 --- a/src/driver/src/main/java/com/edgedb/driver/binary/duplexers/ChannelDuplexer.java +++ b/src/driver/src/main/java/com/edgedb/driver/binary/duplexers/ChannelDuplexer.java @@ -350,9 +350,9 @@ public CompletionStage disconnect() { if(this.channel.isOpen()) { return send(new Terminate()) - .thenCompose(v -> ChannelCompletableFuture.completeFrom(this.channel.disconnect())); + .thenCompose(v -> ChannelCompletableFuture.completeFrom(this.channel.close())); } - return ChannelCompletableFuture.completeFrom(this.channel.disconnect()); + return ChannelCompletableFuture.completeFrom(this.channel.close()); } } diff --git a/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBBinaryClient.java b/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBBinaryClient.java index 870abe9..b2b0dee 100644 --- a/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBBinaryClient.java +++ b/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBBinaryClient.java @@ -299,7 +299,13 @@ public final CompletionStage executeQuery( @NotNull ExecutionArguments args ) { logger.debug("Execute request: is connected? {}", getDuplexer().isConnected()); - + + if(!getDuplexer().isConnected()) { + // TODO: check for recursion + return connect() + .thenCompose(v -> executeQuery(args)); + } + final var hasReleased = new AtomicBoolean(); return CompletableFuture.runAsync(() -> {