Apns4r icon indicating copy to clipboard operation
Apns4r copied to clipboard

APNs4r::Sender can enter infinite loop. Yikes!

Open noahmiller opened this issue 14 years ago • 2 comments

In APNs4r::Sender#push, if @ssl.write fails there are two bugs in the rescue block:

  1. The ssl connection is not recreated, since @ssl ||= connect is used rather than @ssl = connect.
  2. If the write fails again (e.g. because ssl has disconnected, but isn't nil), retry will be call an infinite number of times.

noahmiller avatar Mar 12 '10 14:03 noahmiller

here's quick-and-dirty fix with exponential delay and total timeout def push notification delay = 2 begin @ssl.write notification.to_s rescue OpenSSL::SSL::SSLError, Errno::EPIPE sleep delay @ssl = connect(@host, @port) delay*=2 and retry if delay < 60 raise Timeout::Error end end

tell me if it's fit you needs and i'll push it.

ponomarevlm avatar Mar 12 '10 17:03 ponomarevlm

Yes, that looks good -- thanks!

noahmiller avatar Mar 12 '10 19:03 noahmiller