Let's talk about Error 29...
As I understand it, this error arises from drifting away from a gym while you're in the middle of attacking it. As you prepare to fight the next Pokemon in the gym, the battle initiates, but before any attacks are launched, the battle gets cut off and you're given an 'Error 29' message. Most annoyingly, there's some cooldown period in which you're not allowed to attack the gym again (~5 minutes), and if you try, you get the same error message. Maybe the cooldown is meant to be an anti-spoofing measure; I honestly don't know. I do know that it's extremely annoying to be fighting a gym, have your avatar drift out of its radius while you're standing still and battling, then get locked out of continuing to fight the gym while the other team gets an opportunity to fill it up again. Going to another gym and starting a battle before trying to fight the original gym didn't work for me this morning; restarting the game doesn't help. Is there any consistent way to circumvent the cooldown period?
I don't think this needs to be a thing at all, frankly. If it's for anti-spoofing, spoofers are running rampant and Error 29 certainly isn't hindering them. If it's some game feature, it should be discontinued. It would be very easy to just keep the player locked in a gym battle (unless they manually quit) for the entire gym roster even if they drift out of range, provided they were in range at the start of the battle.
Answers
I had it happen twice to me today; first while trying to flip a gym before my EX raid (which we were unable to do, probably not because of the error though), then while testing out my new Mewtwo against a gym on my way home. It filled up again as I was waiting for the error to pass. It's happened to me plenty of times before and I'm not sure what exactly causes it, but it's very annoying. The cooldown is inconsistent as well.
It typically happens to me when I'm trying to knock gym defenders out one or two at a time. I live in a high-turnover area where people golden razz as frequently as Tyrion drinks, and there's nothing as infuriating as coming close to taking down a gym only to find out that the 3k Blissey you were one battle away from knocking out has been replenished. And, I typically take gyms down on my own.
My workaround to cater for golden razzes is to try to swat down Blisseys, Chanseys, and Snorlaxes one at a time; others I don't mind taking the 'risk' of going through all at once (idc if a Tyranitar gets golden razzed, since it's so frail anyway). The number of times Error 29 has affected me in such a scenario is countless.
I have never spoofed, I have never used scanners, I don't 'shave' gyms for some selfish benefit - I don't think taking down defenders one at a time is such a crime that I should be persistently punished for doing so with an Error 29 message that typically goes on for 10 minutes. I want Error 29 gone, and I want a more concerted effort from Niantic to rid the game of spoofers and the like.
Error 29 usually happens to me when I'm waiting for the "GO" screen to clear. I'm not battling one at a time, don't move my physical position, and don't notice other attackers. It is just, all of a sudden, "Sorry, you aren't battling this gym." If anything at all correlates, it seems to happen more often in places with marginal cellphone service. It is extremely annoying when it does happen.
I only got this message when trying to fully eliminate the first defender in the queue. It would come up after quitting the battle and trying to reenter and fight the first defender again.
I never get it if I just fight my way through each defender. The problem is with that is it just gives even casual berry feeders a big window to feed the blissey in the first position before it can get knocked out.