NativeScript / NativeScript/NativeScript

Nativescript with Angular - Http call gives error - 'unexpected end of stream on com.android.okhttp.Address@1d8e59ae'

オープン
#9,999 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug-pending-triage
主要言語
TypeScript
スター
25.7k
フォーク
1.7k
平均マージ
1日 5時間
マージ済み PR(30日)
35

説明

Issue Description

I have a NativeScript with angular project. The backend is a rest api written in .NET CORE. I'm trying to make a HTTP call fom the nativescript frontend following the post method under 'request' section as described in the link: https://docs.nativescript.org/http.html#request

Whenever I make a call, I get error -
JS: ERROR Error: Uncaught (in promise): Error: java.io.IOException: unexpected end of stream on com.android.okhttp.Address@1d8e59ae
JS: Error: java.io.IOException: unexpected end of stream on com.android.okhttp.Address@1d8e59ae
JS: at onRequestComplete (file: src\webpack:\ns-blendedsupport-mvp\node_modules@nativescript\core\http\http-request\index.android.js:49:33)
JS: at Object.onComplete (file: src\webpack:\ns-blendedsupport-mvp\node_modules@nativescript\core\http\http-request\index.android.js:38:12)

Reproduction
app.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'
import { NativeScriptHttpClientModule } from "@nativescript/angular";
import { NativeScriptModule } from '@nativescript/angular'
import { NativeScriptCommonModule } from "@nativescript/angular";
import { NativeScriptRouterModule } from "@nativescript/angular";
import { NativeScriptFormsModule } from "@nativescript/angular";
import { AppRoutingModule } from './app-routing.module'

@NgModule({
bootstrap: [AppComponent],
imports: [
NativeScriptModule,
NativeScriptHttpClientModule,
NativeScriptCommonModule,
NativeScriptRouterModule,
NativeScriptFormsModule,
AppRoutingModule,
],
declarations: [AppComponent],
providers: [],
schemas: [NO_ERRORS_SCHEMA],
})
export class AppModule {}

authenticationservice.ts

import { Injectable } from '@angular/core';
import { Http, HttpResponse} from "@nativescript/core";
import { RouterExtensions } from "@nativescript/angular";

import { CommonCodeService } from "./common-code-service";
import { LoginRequestDTO, LoginResponseDTO } from "../data-models/login-model";

@Injectable({
providedIn: 'root'
})
export class AuthenticationService {

loginModelData: LoginRequestDTO = {
Username:"",
Password:""
}

loginResponseData: LoginResponseDTO = {
isLoginSuccess:false,
responseMessage:"",
userId:"",
token:"",
firstname:""
};

isLoginValid: boolean = false;

constructor(
private commonCodeService: CommonCodeService,
private router: RouterExtensions,) { }

login(username: string, password:string) {
this.loginModelData.Username=username;
this.loginModelData.Password=password;
let apiURL = "http://10.0.2.2:4001/api/Login/Login";
let data = JSON.stringify(this.loginModelData);

Http.request({
  url: apiURL,
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  content: data,
}).then(
  (response: HttpResponse) => {
    const result = response.content.toJSON();
    if(result!='' || result!=null)
    {
      this.loginResponseData = <LoginResponseDTO>result;
      if(this.loginResponseData.isLoginSuccess)
      {
        this.isLoginValid=true;
        this.router.navigate(["home"], { clearHistory: true });
      }
      else
      {
        this.isLoginValid=false;
        this.commonCodeService.alert(this.loginResponseData.responseMessage);
      }
    }
    else
    {
      this.commonCodeService.alert('User data not found. Please try again');
    }
  }
);

}
}

Relevant log output (if applicable)
JS: ERROR Error: Uncaught (in promise): Error: java.io.IOException: unexpected end of stream on com.android.okhttp.Address@1d8e59ae
  JS: Error: java.io.IOException: unexpected end of stream on com.android.okhttp.Address@1d8e59ae
  JS:     at onRequestComplete (file: src\webpack:\ns-blendedsupport-mvp\node_modules\@nativescript\core\http\http-request\index.android.js:49:33)
  JS:     at Object.onComplete (file: src\webpack:\ns-blendedsupport-mvp\node_modules\@nativescript\core\http\http-request\index.android.js:38:12)
Environment
package.json

{
"name": "ns-blendedsupport-mvp",
"main": "./src/main.ts",
"version": "1.0.0",
"private": true,
"dependencies": {
"@angular/animations": "~13.2.0",
"@angular/common": "~13.2.0",
"@angular/compiler": "~13.2.0",
"@angular/core": "~13.2.0",
"@angular/forms": "~13.2.0",
"@angular/platform-browser": "~13.2.0",
"@angular/platform-browser-dynamic": "~13.2.0",
"@angular/router": "~13.2.0",
"@auth0/angular-jwt": "^5.0.2",
"@nativescript/angular": "^14.0.4",
"@nativescript/core": "~8.2.0",
"@nativescript/theme": "~3.0.2",
"crypto-js": "^3.3.0",
"nativescript-audio": "^6.2.6",
"nativescript-gif": "^5.0.0",
"nativescript-ui-gauge": "^8.0.1",
"nativescript-vibrate": "^4.0.1",
"nativescript-videoplayer": "^5.0.1",
"rxjs": "~7.5.0",
"zone.js": "~0.11.5"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.2.0",
"@angular/compiler-cli": "~13.2.0",
"@nativescript/android": "8.2.3",
"@nativescript/types": "~8.2.0",
"@nativescript/webpack": "~5.0.6",
"@ngtools/webpack": "~13.2.0",
"typescript": "~4.5.5"
}
}

tsconfig.json

{
"compilerOptions": {
"module": "esnext",
"target": "es2017",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"importHelpers":true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": ["es2017", "dom"],
"baseUrl": ".",
"paths": {
"~/": ["src/"],
"@/": ["src/"]
}
},
"include": ["src/tests//*.ts", "src//.ios.ts", "src/**/.android.ts"],
"files": ["./src/main.ts", "./references.d.ts", "./src/polyfills.ts"],
"exclude": ["node_modules", "platforms", "e2e"]
}

Please accept these terms

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

authenticationservice.ts のリクエストから開始し、@nativescript/core/http/http-request/index.android.js の Android の完了パスと比較します。指定されたエンドポイント http://10.0.2.2:4001/api/Login/Login に対する POST を再現し、その後、報告された「unexpected end-of-stream」エラーなしでリクエストが完了するかどうかを確認します。失敗を再現できる場合は、対象を絞った回帰テストを追加します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, angular, typescript
領域
api, mobile, networking
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。