{"record":{"id":"c65632dbb3bdc77a","repo":"NationalSecurityAgency/ghidra","slug":"error-sending-request","errorCode":null,"errorMessage":"Error sending request: ","messagePattern":"Error sending request: ","errorType":"exception","errorClass":"ElasticException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java","lineNumber":377,"sourceCode":"\t\t\tconnection = (HttpURLConnection) httpURL.openConnection();\n\t\t\tconnection.setRequestMethod(POST);\n\t\t\tconnection.setRequestProperty(\"Content-Type\", \"application/x-ndjson\");\n\t\t\tconnection.setDoOutput(true);\n\t\t\ttry (Writer writer = new OutputStreamWriter(connection.getOutputStream())) {\n\t\t\t\twriter.write(body);\n\t\t\t}\n\t\t\tlastResponseCode = connection.getResponseCode();\n\t\t\tJsonObject resp = grabResponse(connection);\n\t\t\tif (!lastRequestSuccessful()) {\n\t\t\t\tthrow new ElasticException(parseErrorJSON(resp));\n\t\t\t}\n\t\t\treturn resp;\n\t\t}\n\t\tcatch (URISyntaxException e) {\n\t\t\tthrow new ElasticException(\"Error parsing URL: \" + e.getMessage());\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new ElasticException(\"Error sending request: \" + e.getMessage());\n\t\t}\n\t\tcatch (JsonParseException e) {\n\t\t\tthrow new ElasticException(\"Error parsing response: \" + e.getMessage());\n\t\t}\n\t\tfinally {\n\t\t\tif (connection != null) {\n\t\t\t\tconnection.disconnect();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic JsonObject executeURIOnly(String command, String path) throws ElasticException {\n\t\tHttpURLConnection connection = null;\n\t\ttry {\n\t\t\tURL httpURL = new URI(httpURLbase + path).toURL();\n\t\t\tconnection = (HttpURLConnection) httpURL.openConnection();\n\t\t\tconnection.setRequestMethod(command);\n\t\t\tconnection.setDoOutput(true);","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java#L359-L395","documentation":"IOException handler inside executeBulk. Bulk requests send large application/x-ndjson bodies, so beyond the usual connect/DNS/TLS failures this commonly fires on write-side problems: connection reset while streaming a big body, or a proxy rejecting/aborting an oversized POST.","triggerScenarios":"Socket failure while opening the connection or streaming the NDJSON body; getResponseCode/read failure; reset on a very large bulk POST; proxy client_max_body_size or timeout aborting the request; null error stream in grabResponse.","commonSituations":"Bulk-ingesting many vectors at once against an ES behind a proxy with a small body limit; ES still starting; network flakiness during long bulk writes; TLS misconfig on https ES.","solutions":["Reduce the bulk batch size (number of action/source pairs per executeBulk call) so each POST fits proxy limits and completes before idle timeouts.","Classify by subtype: ConnectException -> ES down/wrong port; SocketTimeoutException -> raise timeout / shrink batch; SSLHandshakeException -> fix truststore.","Retry the failed batch with backoff; bulk operations are not atomic so de-dup on re-run if your action has an id."],"exampleFix":"// before\nc.executeBulk(\"_bulk\", wholeNdjson);\n// after\nfor (String chunk : splitNdjson(wholeNdjson, 1000)) {\n    retryTransient(() -> c.executeBulk(\"_bulk\", chunk), 3);\n}","handlingStrategy":"retry","validationCode":"public static List<String> chunked(String ndjson, int pairsPerChunk) {\n    // split NDJSON into bounded chunks so each POST fits proxy limits\n    List<String> out = new ArrayList<>(); StringBuilder b = new StringBuilder(); int n = 0;\n    for (String line : ndjson.split(\"\\n\")) { b.append(line).append('\\n'); if ((++n & 1) == 0 && n/2 >= pairsPerChunk) { out.add(b.toString()); b.setLength(0); } }\n    if (b.length() > 0) out.add(b.toString());\n    return out;\n}","typeGuard":null,"tryCatchPattern":"for (String chunk : chunked(ndjson, 1000)) {\n    for (int attempt = 0; ; attempt++) {\n        try { conn.executeBulk(\"_bulk\", chunk); break; }\n        catch (ElasticException e) {\n            if (!e.getMessage().startsWith(\"Error sending request\") || attempt == 3) throw e;\n            Thread.sleep(500L << attempt);\n        }\n    }\n}","preventionTips":["Bound the number of action/source pairs per bulk POST.","Raise proxy client_max_body_size / bulk limits above your batch size.","Retry failed batches; design actions to be idempotent on re-run."],"tags":["network","io","bulk","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}