Pixel 2 API 29 httpClient not working correctly

故事扮演 提交于 2020-08-11 03:45:12

问题


I have finally released a nativescript app to the store. iOS is good, almost all versions of Android are good. However, someone downloaded onto a Pixel 2 with API 29 and told me they couldn't login. I downloaded an emulator and sure enough, the http request never goes through.

This is my login code in my service:

getLogin(args): RxObservable<Object> {
    var params = this.buildQueryParams(args);
    let headers = this.createRequestHeader();
    return this.http.get(`${this.serverUrl}AuthenticateUser${params}`);
}

This is my login component using it:

login() {
  this.isLoggingIn = true;
  Object.assign(this.user, this.loginForm.value);
  this.httpSub = this.httpget.getLogin(this.user)
  .pipe(
    map(res=>res),
    catchError((err: string) => {
      const errMsg = "There was a network error, please check your connection or try again later";
      return of(errMsg)
  })
)
  .subscribe((result) => {
    if(result['Status'] === "SUCCESS"){
      this.onGetDataSuccess(result);
    }
    else if(typeof(result) === 'string'){
      this.errorMessage = "There is a connection error.";
      this.isLoggingIn = false;
    }
    else {
      this.errorMessage = "user name or password incorrect";
      this.isLoggingIn = false;
    }
}, (error) => {
  console.log("got an error");
    this.errorMessage = "Verify your username and password.  If you have an account, but are having trouble, call 1-866-706-8665.";
    this.isLoggingIn = false;
});

I'm getting this on the Pixel:

There is a connection error.

In the debugger this is what I see in the Headers on the pixel:

Request URL: http://toolingu.com/ToolingU.WCF.TuAppService/ToolingU.WCF.TuAppService.svc/AuthenticateUser?username=<user>&password=<pw>
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: application/json, text/plain, */*
username: <user>
password: <pw>

This is what I see on the emulators that are working correctly:

Request URL: http://toolingu.com/ToolingU.WCF.TuAppService/ToolingU.WCF.TuAppService.svc/AuthenticateUser?username=<user>&password=<pw>
Request Method: GET
Status Code: 200 OK
Referrer Policy: no-referrer-when-downgrade
Provisional headers are shown
Accept: application/json, text/plain, */*
username: <user>
password: <pw>

It appears the error happens instantly, as if it isn't waiting for a response to come back. Any ideas?


回答1:


Http communications (clear text traffic) are blocked by default from Android Pie (API 29). You will have to enable it by explicitly by adding android:usesCleartextTraffic="true" on application tag of your AndroidManifest.xml



来源:https://stackoverflow.com/questions/57118016/pixel-2-api-29-httpclient-not-working-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!