40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/netsuite/utilities.rb', line 40
def backoff(options = {})
options[:attempts] ||= 8
count = 0
begin
count += 1
yield
rescue Exception => e
exceptions_to_retry = [
Errno::ECONNRESET,
Errno::ETIMEDOUT,
Errno::EHOSTUNREACH,
EOFError,
Wasabi::Resolver::HTTPError,
Savon::SOAPFault,
Savon::InvalidResponseError,
Zlib::BufError,
Savon::HTTPError,
SocketError,
Net::OpenTimeout
]
if defined?(Net::ReadTimeout)
exceptions_to_retry << Net::ReadTimeout
end
exceptions_to_retry << IO::EINPROGRESSWaitWritable if defined?(IO::EINPROGRESSWaitWritable)
exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
exceptions_to_retry << Excon::Error::Timeout if defined?(Excon::Error::Timeout)
exceptions_to_retry << Excon::Error::Socket if defined?(Excon::Error::Socket)
if !exceptions_to_retry.include?(e.class)
raise
end
if e.is_a?(Savon::SOAPFault)
if !e.message.include?("Only one request may be made against a session at a time") &&
!e.message.include?('java.util.ConcurrentModificationException') &&
!e.message.include?('com.netledger.common.exceptions.NLDatabaseOfflineException') &&
!e.message.include?('com.netledger.database.NLConnectionUtil$NoCompanyDbsOnlineException') &&
!e.message.include?('com.netledger.cache.CacheUnavailableException') &&
!e.message.include?('An unexpected error occurred.') &&
!e.message.include?('Session invalidation is in progress with different thread') &&
!e.message.include?('SuiteTalk concurrent request limit exceeded. Request blocked.') &&
!e.message.include?('The Connection Pool is not intialized.') &&
!e.message.include?('The Connection Pool is not intiialized.')
raise
end
end
if count >= options[:attempts]
raise
end
sleep(count)
retry
end
end
|