{"record":{"id":"ced16c89f698467a","repo":"apache/druid","slug":"trying-to-re-connect-to-graphite-server","errorCode":null,"errorMessage":"Trying to re-connect to graphite server","messagePattern":"Trying to re-connect to graphite server","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitter.java","lineNumber":208,"sourceCode":"                  graphiteEvent.getTimestamp()\n              );\n              graphite.send(\n                  graphiteEvent.getEventPath(),\n                  graphiteEvent.getValue(),\n                  graphiteEvent.getTimestamp()\n              );\n            }\n          }\n          catch (InterruptedException | IOException e) {\n            log.error(e, e.getMessage());\n            if (e instanceof InterruptedException) {\n              Thread.currentThread().interrupt();\n              break;\n            } else if (e instanceof SocketException) {\n              // This is antagonistic to general Closeable contract in Java,\n              // it is needed to allow re-connection in case of the socket is closed due long period of inactivity\n              graphite.close();\n              log.warn(\"Trying to re-connect to graphite server\");\n              graphite.connect();\n            }\n          }\n        }\n      }\n      catch (Exception e) {\n        log.error(e, e.getMessage());\n        if (e instanceof InterruptedException) {\n          Thread.currentThread().interrupt();\n        }\n      }\n    }\n  }\n\n  @Override\n  public void flush()\n  {\n    if (started.get()) {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitter.java#L190-L226","documentation":"The Graphite emitter's send thread keeps a long-lived socket to the Graphite server. When a SocketException occurs (typically the socket being closed by the server or NAT after long inactivity), the emitter closes the stale connection, logs this warning, and immediately reconnects so subsequent events are not lost.","triggerScenarios":"The graphite socket raises SocketException during event flush: Graphite server closed an idle connection, network interruption, firewall dropping the long-lived TCP session, or Graphite restart.","commonSituations":"Production setups with idle periods longer than the server's or an intermediary's TCP idle timeout; Graphite/carbon relay restarts; containerized environments where idle connections are reaped.","solutions":["Confirm Graphite/carbon is reachable and not restarting; check server-side idle timeouts.","Enable the emitter's flush period/waitForTime settings so connections see periodic traffic, or enable TCP keepalive on the host to keep NAT/firewall state alive.","Verify network appliances (LBs, NAT gateways) between Druid and Graphite are not silently dropping idle flows; if they are, this warning is expected benign self-healing.","If reconnection itself fails repeatedly, check DNS resolution and graphite host/port configuration (graphite.hostname, graphite.port)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"try (Socket s = new Socket()) {\n  s.connect(new InetSocketAddress(graphiteHost, graphitePort), 3000);\n} // pre-check connectivity before emitting","typeGuard":null,"tryCatchPattern":"catch (InterruptedIOException e) {\n  Thread.currentThread().interrupt();\n  break;\n} catch (SocketException e) {\n  graphite.close();\n  graphite.connect(); // emitter reconnects automatically\n}","preventionTips":["Enable TCP keepalive or send periodic heartbeats to keep idle sessions alive.","Align emitter flush period with firewall/NAT idle timeouts so the socket carries traffic.","Monitor this warning rate; a persistent stream means Graphite or the network is flapping.","Verify graphite host/port config after any Graphite/carbon topology change."],"tags":["graphite","socket","reconnect","network"],"backgroundTag":"broken-pipe","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}