@@ -51,8 +51,6 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
51
51
# SSL key passphrase
52
52
config :ssl_key_passphrase , :validate => :password , :default => nil
53
53
54
- config :message_format , :validate => :string , :obsolete => "This setting is obsolete. The event will be formatted according to the codec used"
55
-
56
54
class Client
57
55
public
58
56
def initialize ( socket , logger )
@@ -85,8 +83,12 @@ def setup_ssl
85
83
require "openssl"
86
84
87
85
@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
90
92
if @ssl_verify
91
93
@cert_store = OpenSSL ::X509 ::Store . new
92
94
# Load the system default certificate path to the store
@@ -150,8 +152,8 @@ def register
150
152
begin
151
153
client_socket = connect unless client_socket
152
154
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
155
157
# don't expect any reads, but a readable socket might
156
158
# mean the remote end closed, so read it and throw it away.
157
159
# we'll get an EOFError if it happens.
@@ -162,7 +164,7 @@ def register
162
164
# Now send the payload
163
165
client_socket . syswrite ( payload ) if w . any?
164
166
rescue => e
165
- @logger . warn ( "tcp output exception" , :host => @host , :port => @port ,
167
+ @logger . warn ( "tcp output exception, will retry " , :host => @host , :port => @port ,
166
168
:exception => e , :backtrace => e . backtrace )
167
169
client_socket . close rescue nil
168
170
client_socket = nil
@@ -204,4 +206,4 @@ def server?
204
206
def receive ( event )
205
207
@codec . encode ( event )
206
208
end # def receive
207
- end # class LogStash::Outputs::Tcp
209
+ end # class LogStash::Outputs::Tcp
0 commit comments