diff --git a/CHANGELOG.md b/CHANGELOG.md index 313b5e3f8b..00488178c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [unreleased] ### Added +- [#7081](https://github.com/apache/trafficcontrol/issues/7081) *Traffic Router* Added better log messages for TR connection exceptions. - [#7089](https://github.com/apache/trafficcontrol/issues/7089) *Traffic Router* Added the ability to specify HTTPS certificate attributes. - [#7109](https://github.com/apache/trafficcontrol/pull/7109) *Traffic Router* Removed `dnssec.zone.diffing.enabled` and `dnssec.rrsig.cache.enabled` parameters. - [#7075](https://github.com/apache/trafficcontrol/pull/7075) *Traffic Portal* Added the `lastUpdated` field to all delivery service forms. diff --git a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java index db475d1ec6..0a0702960f 100644 --- a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java +++ b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/protocol/TCP.java @@ -17,11 +17,13 @@ import java.io.DataInputStream; import java.io.DataOutputStream; +import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; +import java.net.SocketTimeoutException; import java.nio.channels.Channels; import org.apache.logging.log4j.LogManager; @@ -91,6 +93,7 @@ class TCPSocketHandler implements SocketHandler { @Override @SuppressWarnings("PMD.EmptyCatchBlock") public void run() { + InetAddress client = null; if (cancel) { cleanup(); return; @@ -101,7 +104,7 @@ public void run() { DataOutputStream os = new DataOutputStream(socket.getOutputStream()) ) { socket.setSoTimeout(getReadTimeout()); - final InetAddress client = socket.getInetAddress(); + client = socket.getInetAddress(); final int length = is.readUnsignedShort(); final byte[] request = new byte[length]; @@ -112,6 +115,20 @@ public void run() { os.write(response); } catch (final WireParseException e) { // This is already recorded in the access log + } catch (final SocketTimeoutException e) { + String hostAddress = "unknown"; + if (client != null) { + hostAddress = client.getHostAddress(); + } + LOGGER.error("The socket with the Client at: " + + hostAddress + " has timed out. Error: " + e.getMessage()); + } catch (final EOFException e) { + String hostAddress = "unavailable"; + if (client != null) { + hostAddress = client.getHostAddress(); + } + LOGGER.error("The client at " + hostAddress + + " has closed the connection prematurely. Error: " + e.getMessage()); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } finally {