Avoid calling getRemoteEndpoint() twice