From 2b4d507494aa68a43833ce01e966a5ad86f7b269 Mon Sep 17 00:00:00 2001 From: Manuel Polo Date: Sun, 25 Oct 2026 14:56:05 +0000 Subject: [PATCH] test(live): answer the close frame so the mock server shuts down on time The mock WebSocket server never answered the client's close frame, so the server side of the socket kept its read loop alive and MockWebServer.shutdown() sometimes gave up after five seconds ('Gave up waiting for queue to shut down'), failing a LiveConnectionTest at teardown. Answering onClosing completes the close handshake. --- .../java/com/qtsurfer/api/sdk/LiveConnectionTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/com/qtsurfer/api/sdk/LiveConnectionTest.java b/src/test/java/com/qtsurfer/api/sdk/LiveConnectionTest.java index 301e7df..e97953c 100644 --- a/src/test/java/com/qtsurfer/api/sdk/LiveConnectionTest.java +++ b/src/test/java/com/qtsurfer/api/sdk/LiveConnectionTest.java @@ -100,6 +100,16 @@ public void onOpen(WebSocket socket, okhttp3.Response response) { if (socketConnections.incrementAndGet() == 1) firstSocket.set(socket); } + /** + * Answer the client's close frame. Left unanswered, the server side of the socket keeps its + * read loop alive until the client gives up, and {@code MockWebServer.shutdown()} then waits + * out its five seconds ("Gave up waiting for queue to shut down") on some runs. + */ + @Override + public void onClosing(WebSocket socket, int code, String reason) { + socket.close(code, reason); + } + @Override public void onMessage(WebSocket socket, okio.ByteString bytes) { try {