Skip to content

Commit b3bc73c

Browse files
author
Jaspreet Grewal
committed
DNS lookup is done on every reconnect attempt. Caching the machine address for the lifetime of the application is problematic in a dynamic enviroment like docker containers. If the machine address changes, applications need to be restarted to pick up the correct address and log correctly.
1 parent 7661a1e commit b3bc73c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/fluentd/logger/sender/RawSocketSender.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public class RawSocketSender implements Sender {
5252

5353
private String name;
5454

55+
private String host;
56+
57+
private int port;
58+
5559
private ErrorHandler errorHandler = DEFAULT_ERROR_HANDLER;
5660

5761
public RawSocketSender() {
@@ -71,6 +75,8 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
7175
msgpack = new MessagePack();
7276
msgpack.register(Event.class, Event.EventTemplate.INSTANCE);
7377
pendings = ByteBuffer.allocate(bufferCapacity);
78+
this.host = host;
79+
this.port = port;
7480
server = new InetSocketAddress(host, port);
7581
this.reconnector = reconnector;
7682
name = String.format("%s_%d_%d_%d", host, port, timeout, bufferCapacity);
@@ -80,6 +86,7 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
8086
private void connect() throws IOException {
8187
try {
8288
socket = new Socket();
89+
server = new InetSocketAddress(host, port);
8390
socket.connect(server, timeout);
8491
out = new BufferedOutputStream(socket.getOutputStream());
8592
} catch (IOException e) {

0 commit comments

Comments
 (0)