{"record":{"id":"b0e268044954b007","repo":"redis/jedis","slug":"failed-to-create-input-output-stream","errorCode":null,"errorMessage":"Failed to create input/output stream","messagePattern":"Failed to create input/output stream","errorType":"exception","errorClass":"JedisConnectionException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/Connection.java","lineNumber":591,"sourceCode":"          appliedSoTimeout = -1;\n          applyCurrentTimeout();\n        } else {\n          defaultTimeoutSource.setDefaults(socket.getSoTimeout(), getBlockingSoTimeout());\n        }\n\n\n        outputStream = new RedisOutputStream(socket.getOutputStream());\n        inputStream = new RedisInputStream(socket.getInputStream());\n\n        himportState.reset(); // a fresh socket lost any server-side HIMPORT fieldsets\n\n      } catch (JedisConnectionException jce) {\n\n        throw markBroken(jce);\n\n      } catch (IOException ioe) {\n\n        throw markBroken(new JedisConnectionException(\"Failed to create input/output stream\", ioe));\n\n      } catch (RuntimeException ex) {\n\n        throw markBroken(ex);\n\n      } catch (Error err) {\n\n        throw markBroken(err);\n\n      } finally {\n\n        if (broken) {\n          IOUtils.closeQuietly(socket);\n        }\n      }\n    }\n  }\n","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/Connection.java#L573-L609","documentation":"During Connection.connect(), after the TCP socket is opened the client wraps it in input/output streams (and reader/writer). An IOException there means the connection could not be fully established despite the socket succeeding; it is marked broken and rethrown as JedisConnectionException.","triggerScenarios":"connect() fails creating BufferedInputStream/BufferedOutputStream or the RESP reader/writer: socket closed concurrently, SSL handshake-derived stream failure, or OS-level socket error immediately after connect.","commonSituations":"TLS misconfiguration (wrong truststore causing stream setup failure downstream), proxy or LB resetting connections immediately after accept, resource exhaustion (too many open files), half-open sockets in containerized environments.","solutions":["Inspect the wrapped IOException cause for the real error (SSL, EMFILE, connection reset).","Check TLS/SSL configuration (truststore, SNI, certificate) when connecting to a TLS-enabled Redis.","Verify file-descriptor limits (ulimit) if errors correlate with load.","Test network path (proxy/LB/firewall) for immediate post-connect resets."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight: TLS reachability of the endpoint\ntry (Socket s = sslSocketFactory.createSocket(host, port)) { s.startHandshake(); }","typeGuard":null,"tryCatchPattern":"try {\n  RedisClient.create(...).build();\n} catch (JedisConnectionException e) {\n  Throwable root = e.getCause(); // inspect the wrapped IOException/SSL error\n  throw new ConfigException(\"Cannot establish streams to \" + host + \":\" + port, root);\n}","preventionTips":["Validate TLS config (truststore, certificates) before deployment","Check ulimit/fd limits on hosts with many connections","Test network path through proxies/LBs for post-connect resets","Use the builder's connection validation at startup rather than failing lazily"],"tags":["redis","connection","io","tls"],"backgroundTag":"network-request-failed","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}