the error is actually pretty clear - something is preventing the RPC connection from happening. What bothers me is that this is intermittent. Usually you can either do a RPC call or you can't.
Let me first say that RPC connection errors are related to the RPC protocol, which simply put has two phases - the fist being kind of negotioation on port 135 and the 2nd being the actual conversation over a random port from the dynamic port range (49152 to 65535).
So you should first make sure the corresponding FW rules are allowionig this, although I will assume that this is already the case as you mentioned that you can make the connection at some point.
Can you please check the the status of the "Remote Registry Service" as this happens? Do this on boths sides, please. Any errors, any service crashes or so?
Please check also the System and Application event logs, do you see any related events there?
What is the exact error when you try renaming direclty on B?
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)