{"record":{"id":"23056cb858a7b78f","repo":"pentaho/pentaho-kettle","slug":"unable-to-connect-to-the-socketwriter-in-the-timeout-in-23056c","errorCode":null,"errorMessage":"Unable to connect to the SocketWriter in the \" + TIMEOUT_IN_SECONDS + \"s timeout period.","messagePattern":"Unable to connect to the SocketWriter in the \" \\+ TIMEOUT_IN_SECONDS \\+ \"s timeout period\\.","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/socketreader/SocketReader.java","lineNumber":126,"sourceCode":"            Thread.sleep( 1000 );\n          }\n        }\n\n        if ( lastException != null ) {\n          logError( \"Error initialising step: \" + lastException.toString() );\n          logError( Const.getStackTracker( lastException ) );\n          if ( data.socket != null ) {\n            data.socket.shutdownInput();\n            data.socket.shutdownOutput();\n            data.socket.close();\n            logError( \"Closed connection to data socket to \"\n              + environmentSubstitute( meta.getHostname() ) + \" port \" + environmentSubstitute( meta.getPort() ) );\n          }\n\n          throw lastException;\n        } else {\n          if ( data.inputStream == null ) {\n            throw new KettleException( \"Unable to connect to the SocketWriter in the \"\n              + TIMEOUT_IN_SECONDS + \"s timeout period.\" );\n          }\n        }\n\n        data.rowMeta = new RowMeta( data.inputStream ); // This is the metadata\n        first = false;\n      }\n      r = data.rowMeta.readData( data.inputStream );\n\n      incrementLinesInput();\n\n      if ( checkFeedback( getLinesInput() ) ) {\n        logBasic( BaseMessages.getString( PKG, \"SocketReader.Log.LineNumber\" ) + getLinesInput() );\n      }\n\n      putRow( data.rowMeta, r );\n    } catch ( KettleEOFException e ) {\n      setOutputDone(); // finished reading.","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/socketreader/SocketReader.java#L108-L144","documentation":"SocketReader.processRow() retries connecting to the companion SocketWriter step's host/port for a fixed timeout (TIMEOUT_IN_SECONDS). If after the timeout the connection attempt loop exits without lastException (or the stream is still null), it throws this KettleException indicating the socket handshake never completed in time.","triggerScenarios":"Running a transformation where a SocketReader step's target SocketWriter is not yet started, listens on a different host/port, is blocked by a firewall, or the hostname/port variables resolve incorrectly; also when connection succeeds but the object input stream is null.","commonSituations":"Clustered/parallel execution ordering issues where reader starts before writer; typo in port number; localhost vs container hostname mismatch in Docker/Kubernetes; firewall dropping the port.","solutions":["Confirm the SocketWriter step runs before/alongside the reader and its port matches the reader's configured port (check variable substitution values in logs).","Increase startup ordering: ensure both steps belong to the same executing transformation and the writer's 'accept' is not delayed by slow init.","Test connectivity from the reader host: telnet/nc to the writer host:port.","Check firewall/iptables/security-group rules for the chosen port.","Verify hostname resolves correctly (avoid stale /etc/hosts or wrong container DNS names)."],"exampleFix":"// before\n// reader port: 8080, writer bound to 8081\n// after\n// set SocketReader port = SocketWriter port = 8081 in step settings","handlingStrategy":"retry","validationCode":"try (Socket s = new Socket()) { s.connect(new InetSocketAddress(host, port), 5000); } catch (IOException e) { /* writer not reachable yet */ }","typeGuard":null,"tryCatchPattern":"catch (KettleException e) {\n  if (e.getMessage().contains(\"SocketWriter\")) {\n    // wait and retry the transformation once the writer step is confirmed started\n  }\n}","preventionTips":["Ensure SocketWriter initialization precedes SocketReader in execution order.","Verify host/port variables resolve identically in both steps' logs.","Pre-test port reachability with nc/telnet in clustered environments.","Keep ports out of ephemeral ranges and open them in firewalls."],"tags":["kettle","socket","timeout","cluster"],"backgroundTag":"request-timeout","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}