Login process fails on concurrency
Since rbf55d0d38d01, the rpc.login method is called first which close the CONNECTION. If there are a second RPC call in parallel, it will lost the session parameters and so a 401 exception (Unauthorized) is raised.
Instead the login process should only change the CONNECTION once the login succeed.