Improved reconnect timeout logic.