gelfj
gelfj copied to clipboard
Closing connection through timeout
Hi. Can you add support of closing connection after a period of inactivity
Here is the simple example what I want (class GelfTCPSender):
try {
// reconnect if necessary or 5 min timeout occurred
if (socket == null || os == null || lastSendTime + 5 * 60 * 1000 < System.currentTimeMillis()) {
if (socket != null){
socket.close();
}
socket = new Socket(host, port);
os = socket.getOutputStream();
}
os.write(message.toTCPBuffer().array());
lastSendTime = System.currentTimeMillis();
return true;
} catch (IOException e) {
// if an error occours, signal failure
socket = null;
return false;
}
I have some problems with firewall and keep-alive sessions.
Would tcp keepalive resolve this issue?