lib/envoy/client/trunk.rb in envoy-proxy-0.0.8 vs lib/envoy/client/trunk.rb in envoy-proxy-0.0.9

- old
+ new

@@ -41,22 +41,23 @@ def receive_keepalive end def receive_message message - STDERR.puts message + t = Time.now.strftime("%F %T") + STDERR.puts t + " " + message.split("\n").join("\n#{t.gsub(/./, ' ')} ") end def receive_halt EventMachine.stop_event_loop end def unbind - if @options[:reconnect] - STDERR.puts "No connection. Reconnecting in #{@options[:reconnect]}s." - EM.add_timer @options[:reconnect] do - @options[:reconnect] *= 2 + if r = @options[:reconnect] + STDERR.puts "Lost connection. Reconnecting in #{r[0]}s." + EM.add_timer r[0] do + @options[:reconnect] = [r[1], r[0] + r[1]] Trunk.start @options end else if options[:did_connect] STDERR.puts "Connection lost. Not point reconnecting because the host is randomly generated." @@ -67,10 +68,10 @@ end end def ssl_handshake_completed options[:did_connect] = true - options[:reconnect] = 1 if options[:hosts] + options[:reconnect] = [0, 1] if options[:hosts] o = options.dup o.delete(:local_host) send_object :options, o end \ No newline at end of file