{"record":{"id":"0075c040cf405f5a","repo":"nathanmarz/storm","slug":"client-connection-should-not-receive-any-messages","errorCode":null,"errorMessage":"Client connection should not receive any messages","messagePattern":"Client connection should not receive any messages","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"storm-netty/src/jvm/backtype/storm/messaging/netty/Client.java","lineNumber":208,"sourceCode":"    }\n\n    /**\n     * close_n_release() is invoked after all messages have been sent.\n     */\n    void  close_n_release() {\n        if (channelRef.get() != null)\n            channelRef.get().close().awaitUninterruptibly();\n\n        //we need to release resources\n        new Thread(new Runnable() {\n            @Override\n            public void run() {\n                factory.releaseExternalResources();\n            }}).start();\n    }\n\n    public TaskMessage recv(int flags) {\n        throw new RuntimeException(\"Client connection should not receive any messages\");\n    }\n\n    void setChannel(Channel channel) {\n        channelRef.set(channel);\n        //reset retries\n        if (channel != null)\n            retries.set(0);\n    }\n\n}\n\n\n\n\n","sourceCodeStart":190,"sourceCodeEnd":223,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-netty/src/jvm/backtype/storm/messaging/netty/Client.java#L190-L223","documentation":"The Netty messaging layer is unidirectional per connection: a Client only sends to a server, it never receives. Client.recv is deliberately implemented as an unconditional throw at Client.java:208 to catch misuse of the connection API.","triggerScenarios":"Any direct call to client.recv(flags) on a backtype.storm.messaging.netty.Client instance — typically code written against the IConnection interface treating a client connection like a server connection.","commonSituations":"Generic code iterating over IConnection objects and calling recv on all of them; testing code that assumes request/response semantics on the netty transport; refactoring server-side read loops into shared client/server utilities.","solutions":["Do not call recv on Client; receive messages on the Server connection instead.","Check the concrete connection type (instanceof Client) before invoking recv in generic IConnection code.","Use a Server (listen on a port) if you need to receive messages.","Rely on the Client's internal async response handling rather than a recv loop."],"exampleFix":"// before\nTaskMessage msg = client.recv(0); // always throws\n// after\nTaskMessage msg = server.recv(0);","handlingStrategy":"type-guard","validationCode":"if (conn instanceof backtype.storm.messaging.netty.Client) { /* do not call recv */ }","typeGuard":"boolean isReceivingConnection(IConnection c) {\n    return !(c instanceof backtype.storm.messaging.netty.Client);\n}","tryCatchPattern":"// recv on Client is guaranteed to throw; guard with instanceof instead of catching","preventionTips":["Remember the netty transport is unidirectional: Client sends, Server receives.","Check concrete types in code iterating over IConnection instances.","Never write symmetric send/recv wrappers around Client and Server."],"tags":["netty","client","api-misuse","messaging"],"backgroundTag":"unsupported-operation","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"}