Untrapped connect() failures would raise up to the mainloop, causing a
burst of reconnect attempts without delay. Fix by rescuing in
reconnect() and retrying after waiting.
disconnect(message)
end
- if will_wait
- log "\n\nDisconnected\n\n"
+ begin
+ if will_wait
+ log "\n\nDisconnected\n\n"
- quit if $interrupted > 0
+ quit if $interrupted > 0
- log "\n\nWaiting to reconnect\n\n"
- sleep @config['server.reconnect_wait']
- sleep 10*@config['server.reconnect_wait'] if too_fast
- end
+ log "\n\nWaiting to reconnect\n\n"
+ sleep @config['server.reconnect_wait']
+ sleep 10*@config['server.reconnect_wait'] if too_fast
+ end
- connect
+ connect
+ rescue Exception => e
+ will_wait = true
+ retry
+ end
end
# begin event handling loop