@@ -51,8 +51,6 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
5151 # SSL key passphrase
5252 config :ssl_key_passphrase , :validate => :password , :default => nil
5353
54- config :message_format , :validate => :string , :obsolete => "This setting is obsolete. The event will be formatted according to the codec used"
55-
5654 class Client
5755 public
5856 def initialize ( socket , logger )
@@ -85,8 +83,12 @@ def setup_ssl
8583 require "openssl"
8684
8785 @ssl_context = OpenSSL ::SSL ::SSLContext . new
88- @ssl_context . cert = OpenSSL ::X509 ::Certificate . new ( File . read ( @ssl_cert ) )
89- @ssl_context . key = OpenSSL ::PKey ::RSA . new ( File . read ( @ssl_key ) , @ssl_key_passphrase )
86+ if @ssl_cert
87+ @ssl_context . cert = OpenSSL ::X509 ::Certificate . new ( File . read ( @ssl_cert ) )
88+ if @ssl_key
89+ @ssl_context . key = OpenSSL ::PKey ::RSA . new ( File . read ( @ssl_key ) , @ssl_key_passphrase )
90+ end
91+ end
9092 if @ssl_verify
9193 @cert_store = OpenSSL ::X509 ::Store . new
9294 # Load the system default certificate path to the store
@@ -150,8 +152,8 @@ def register
150152 begin
151153 client_socket = connect unless client_socket
152154 r , w , e = IO . select ( [ client_socket ] , [ client_socket ] , [ client_socket ] , nil )
153- loop do
154- break if ! r . any?
155+ # Read everything first
156+ while r . any? do
155157 # don't expect any reads, but a readable socket might
156158 # mean the remote end closed, so read it and throw it away.
157159 # we'll get an EOFError if it happens.
@@ -162,7 +164,7 @@ def register
162164 # Now send the payload
163165 client_socket . syswrite ( payload ) if w . any?
164166 rescue => e
165- @logger . warn ( "tcp output exception" , :host => @host , :port => @port ,
167+ @logger . warn ( "tcp output exception, will retry " , :host => @host , :port => @port ,
166168 :exception => e , :backtrace => e . backtrace )
167169 client_socket . close rescue nil
168170 client_socket = nil
@@ -204,4 +206,4 @@ def server?
204206 def receive ( event )
205207 @codec . encode ( event )
206208 end # def receive
207- end # class LogStash::Outputs::Tcp
209+ end # class LogStash::Outputs::Tcp
0 commit comments