Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

InetAddress cached #77

Closed
sergiomahs opened this issue Apr 12, 2016 · 5 comments
Closed

InetAddress cached #77

sergiomahs opened this issue Apr 12, 2016 · 5 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@sergiomahs
Copy link

Whenever the first log is sent, the variable hostname is cached in GelfTCPSender. If for example the graylog server is in the cloud and the ip changes, the hostname won't be the correct one anymore, so it has to be recalculated again.

Our workaround is to find the hostname everytime that a log is appended and the Socket is null.

protected Socket createSocket() throws IOException { Socket socket = new Socket(); socket.setSoTimeout(readTimeoutMs); socket.setKeepAlive(keepAlive); InetAddress hostname = InetAddress.getByName(host); socket.connect(new InetSocketAddress(hostname, port), connectTimeoutMs); return socket; }

@mp911de
Copy link
Owner

mp911de commented Apr 13, 2016

Works only with the TCP/Redis-senders as UDP has no connection state.

@mp911de mp911de added this to the 1.9.0 milestone Apr 13, 2016
mp911de added a commit that referenced this issue Apr 14, 2016
The TCP sender does not longer cache the hostname resolution result but performs a host lookup on each connection attempt. The very first hostname resolution is still in place to fail early if the configured hostname cannot be resolved.
@mp911de
Copy link
Owner

mp911de commented Apr 14, 2016

Fixed. I'll release 1.9.0 tomorrow (Apr 15).

@mp911de mp911de closed this as completed Apr 14, 2016
@kirrmann
Copy link

Sorry for digging up this old issue. But the issue seems to be still valid for the UDP sender. Could you please fix this too?

@mp911de
Copy link
Owner

mp911de commented Jul 1, 2018

@kirrmann UDP has no notion of connection. In any case, GelfUDPSender creates a new InetSocketAddress if an IOException happens.

https://github.com/mp911de/logstash-gelf/blob/master/src/main/java/biz/paluch/logging/gelf/intern/sender/GelfUDPSender.java#L91

@kirrmann
Copy link

kirrmann commented Jul 1, 2018

Sorry my fault. I only took a look at the code of version 1.7.0, which is the one I'm using. But you're right, in the current version it should work and try to resolve again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants