This is needed to deal with hostname changes during lifetime of a session. (cherry picked from commit 7c325b74)