As I discuss in this question, the Udyoga Parva of the Mahabharata describes how Krishna goes to Duryodhana on behalf of the Pandavas in order to try to negotiate peace and avert the Mahabharata war. When he hears that Krishna is coming, Duryodhana hatches a plan to kidnap and imprison Krishna. But Vidura advises against it, because of how powerful Krishna is:
O Duryodhana, listen now to these words of mine. At the gates of Saubha, that foremost of monkeys, known by the name of Dvivida, covered Kesava with a mighty shower of stones. Desirous of seizing Madhava by putting forth all his prowess and exertion, he did not yet succeed in seizing him. Seekest thou to apprehend that Kesava by force?
For those who don't know, Dvivida was one of the major Vanaras in the Ramayana; along with his twin brother Mainda, he helped Rama in his war in Lanka. As a result, he was blessed with a long life, which is why he was still alive at the time of Krishna. But Dvivida did not have such a positive relationship with Rama's next birth Krishna. As I discuss in this answer, for some strange reason Dvivida was friends with the demon Narakasura, so when Krishna killed Narakasura (the reason behind Deepavali), Dvivida was furious. The Srimad Bhagavatam describes the various things he did to take revenge on Krishna:
To avenge the death of his friend [Naraka], the ape Dvivida ravaged the land, setting fires that burned cities, villages, mines and cowherd dwellings. Once Dvivida tore up a number of mountains and used them to devastate all the neighboring kingdoms, especially the province of Ānarta, wherein dwelt his friend’s killer, Lord Hari. Another time he entered the ocean and, with the strength of ten thousand elephants, churned up its water with his arms and thus submerged the coastal regions. The wicked ape tore down the trees in the hermitages of exalted sages and contaminated their sacrificial fires with his feces and urine. Just as a wasp imprisons smaller insects, he arrogantly threw both men and women into caves in a mountain valley and sealed the caves shut with boulders.
Finally Dvivida harassed a group of young women who were with Krishna's brother Balarama, so Balarama killed him after an epic battle.
But my question is, what is the story of Dvivida trying to kidnap Krishna "at the gates of Saubha" as Vidura says? Saubha was the floating iron city of the king Shalva; Krishna killed Shalva and destroyed Saubha when Shalva attacked Dwaraka, as described in the Srimad Bhagavatam.
So what was Dvivida's role in Krishna's battle with Shalva? Did he use Dwaraka being under attack as an opportunity to try to kidnap Krishna? Or was Dvivida in league with Shalva?