{"record":{"id":"19e34cfbacd41c02","repo":"nathanmarz/storm","slug":"client-is-being-closed-and-does-not-take-requests-any-more","errorCode":null,"errorMessage":"Client is being closed, and does not take requests any more","messagePattern":"Client is being closed, and does not take requests any more","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"storm-netty/src/jvm/backtype/storm/messaging/netty/Client.java","lineNumber":126,"sourceCode":"    /**\n     * # of milliseconds to wait per exponential back-off policy\n     */\n    private int getSleepTimeMs()\n    {\n        int backoff = 1 << retries.get();\n        int sleepMs = base_sleep_ms * Math.max(1, random.nextInt(backoff));\n        if ( sleepMs > max_sleep_ms )\n            sleepMs = max_sleep_ms;\n        return sleepMs;\n    }\n\n    /**\n     * Enqueue a task message to be sent to server\n     */\n    public void send(int task, byte[] message) {\n        //throw exception if the client is being closed\n        if (being_closed.get()) {\n            throw new RuntimeException(\"Client is being closed, and does not take requests any more\");\n        }\n\n        try {\n            message_queue.put(new TaskMessage(task, message));\n        } catch (InterruptedException e) {\n            throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * Take all enqueued messages from queue\n     * @return\n     * @throws InterruptedException\n     */\n    MessageBatch takeMessages()  throws InterruptedException {\n        //1st message\n        MessageBatch batch = new MessageBatch(buffer_size);\n        Object msg = message_queue.take();","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-netty/src/jvm/backtype/storm/messaging/netty/Client.java#L108-L144","documentation":"Netty Client.send enqueues messages to a transport queue, but once the client is shutting down (being_closed flag set), it refuses new work. Calling send after close() was initiated throws this RuntimeException at Client.java:126, protecting against writes to a closing connection.","triggerScenarios":"Calling client.send(task, message) after client.close() has been called, or concurrently while close() is in progress; a supervisor/worker shutdown path racing with topology message dispatch.","commonSituations":"Worker shutdown while bolts still try to emit tuples; custom code holding a Client reference past connection teardown; storm shutdown hooks racing with in-flight send loops.","solutions":["Stop sending messages before initiating client.close(); track the closed state in application code.","Guard sends with a shutdown latch: set your own flag before close() and skip sends afterwards.","Recreate the Client if you need to send after a previous one was closed (it is not restartable).","Catch RuntimeException around send during shutdown windows and drop/retry via a live client."],"exampleFix":"// before\nclient.close();\nclient.send(task, tupleBytes); // throws\n// after\nclient.send(task, tupleBytes);\nclient.close();","handlingStrategy":"try-catch","validationCode":"if (clientClosed.get()) { /* skip or recreate client */ }","typeGuard":null,"tryCatchPattern":"try {\n    client.send(task, message);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"does not take requests any more\")) {\n        // recreate client or drop message during shutdown\n    } else {\n        throw e;\n    }\n}","preventionTips":["Close clients only after all emitting threads have stopped.","Track shutdown state in application code before calling close().","Coordinate close() with worker shutdown hooks and topology lifecycle."],"tags":["netty","client","shutdown","messaging"],"backgroundTag":"invalid-state-transition","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}