Added check and recovery for connection when creating session internal if connection is null