I thought commiserate was the word I was looking for, but found out that means sympathy for someone else's experience, rather than two or more people mutually feeling sorry for themselves.
Commiserate will do just fine. If A sympathizes with B at the same time B sympathizes with A for the same reason, they commiserate with each other. And this has been going on for a while now.
Of course, a rather less formal phrase would be bitching and moaning. Take your pick.