diff --git a/lib/logstash/outputs/tcp.rb b/lib/logstash/outputs/tcp.rb index fa23d72..dc7adaf 100644 --- a/lib/logstash/outputs/tcp.rb +++ b/lib/logstash/outputs/tcp.rb @@ -51,8 +51,6 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base # SSL key passphrase config :ssl_key_passphrase, :validate => :password, :default => nil - config :message_format, :validate => :string, :obsolete => "This setting is obsolete. The event will be formatted according to the codec used" - class Client public def initialize(socket, logger) @@ -85,8 +83,12 @@ def setup_ssl require "openssl" @ssl_context = OpenSSL::SSL::SSLContext.new - @ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert)) - @ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase) + if @ssl_cert + @ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert)) + if @ssl_key + @ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase) + end + end if @ssl_verify @cert_store = OpenSSL::X509::Store.new # Load the system default certificate path to the store @@ -150,8 +152,8 @@ def register begin client_socket = connect unless client_socket r,w,e = IO.select([client_socket], [client_socket], [client_socket], nil) - loop do - break if !r.any? + # Read everything first + while r.any? do # don't expect any reads, but a readable socket might # mean the remote end closed, so read it and throw it away. # we'll get an EOFError if it happens. @@ -162,7 +164,7 @@ def register # Now send the payload client_socket.syswrite(payload) if w.any? rescue => e - @logger.warn("tcp output exception", :host => @host, :port => @port, + @logger.warn("tcp output exception, will retry", :host => @host, :port => @port, :exception => e, :backtrace => e.backtrace) client_socket.close rescue nil client_socket = nil @@ -204,4 +206,4 @@ def server? def receive(event) @codec.encode(event) end # def receive -end # class LogStash::Outputs::Tcp +end # class LogStash::Outputs::Tcp \ No newline at end of file