you said your chain broke randomly, do you mean you got the message that it couldn't be found?
if so that doesn't mean your chain breaks, it just means you have to walk around a bit till another patch shakes(even if its not the pokemon you were chaining).
then kill that pokemon, return to a safe area(you should always have a fixed spot you return to(outside of the grass) during chaining) and open the dexnav, select the pokemon you wish to chain, and keep going.
the only things that break a chain are a random encounter during(which means you weren't using repels), an NPC walking into the spot where the shaky patch was or you walk to fast and scare the pokemon off.