You need to develop an "inner life." There are things we can do that give us an intrinsic sort of happiness that cannot be taken away or augmented by others. (Though of course we will always be subject to our moods.) I mean spiritual pursuits (whether that is theistically based, non-theistic, meditation, yoga, martial arts, etc.) artistic pursuits, (art, writing, poetry music) intellectual pursuits (you're at PF so I don't have to list those), some kind of physical exercise (sign up for a 5k/10k/half marathon/marathon and start training, even if you've never run before). etc.
Perhaps paradoxically, you don't need to do those on your own, necessarily. There are groups of people who do all these things, (most that don't cost you anything). Yet they develop an internalized sense of satisfaction.
Well, part of this is nothing new for us, the intellectually elite. (haha) Many of us math/physics/science types spend a lot of time online, because unless we are in an academic or otherwise science based profession, we are usually surrounded by people who have no idea what the hell we are talking about.
Rather than trying to "find" friends I think it's best to pursue intrinsic happiness and you'll meet people along the way who are on the same sort of journey. But that's not the goal.
-Dave K