Fix client URI generation to select protocol properly