Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better messages for Traffic Router exceptions #7146

Merged
merged 4 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,6 +93,7 @@ class TCPSocketHandler implements SocketHandler {
@Override
@SuppressWarnings("PMD.EmptyCatchBlock")
public void run() {
InetAddress client = null;
if (cancel) {
cleanup();
return;
Expand All @@ -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];
Expand All @@ -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) {
srijeet0406 marked this conversation as resolved.
Show resolved Hide resolved
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 {
Expand Down