Changing connection API to make session opening synchronous.