The unglamorous answer that has served me best: ask again, immediately, without apologising for it.
"Sorry, your name again?" within the first minute costs nothing. Nobody has ever minded. The thing people are afraid of is asking at minute forty, which is genuinely awkward: but that only happens because you let the first minute pass.
So the rule I use is that if it did not land, I ask before the conversation gets going. It is a two-second repair at minute one and an embarrassment at minute forty, and the only thing standing between them is being willing to look slightly unpolished early.
The other repair worth knowing, for when you are already at minute forty: introduce them to someone else. "Have you met Tom?", and the other person almost always fills their own name in. It works, though it is a trick and it fails if the two already know each other.
And if all else fails, saying "I have completely lost your name and I have been enjoying this too much to admit it" has never once gone badly for me. People are much more forgiving about this than the anxiety suggests, because every one of them has done it.