Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何修复改装中的IOException_Android_Node.js_Sql Server_Retrofit_Rx Android - Fatal编程技术网

Android 如何修复改装中的IOException

Android 如何修复改装中的IOException,android,node.js,sql-server,retrofit,rx-android,Android,Node.js,Sql Server,Retrofit,Rx Android,我一直在从事android项目,该项目的node.js后端与sql server中的数据库通信,IOException不断向我展示: caused by java.io.EOFException: \n not found: limit=0 content=… 这是整个堆栈跟踪: W/System.err: java.io.IOException: unexpected end of stream on Connection{10.0.2.2:1433, proxy=DIRECT hostAd

我一直在从事android项目,该项目的node.js后端与sql server中的数据库通信,IOException不断向我展示:

caused by java.io.EOFException: \n not found: limit=0 content=…
这是整个堆栈跟踪:

W/System.err: java.io.IOException: unexpected end of stream on Connection{10.0.2.2:1433, proxy=DIRECT hostAddress=/10.0.2.2:1433 cipherSuite=none protocol=http/1.1}
                  at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208)
                  at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
W/System.err:     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
                  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
                  at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
                  at okhttp3.RealCall.execute(RealCall.java:92)
                  at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
                  at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:41)
                  at io.reactivex.Observable.subscribe(Observable.java:12036)
                  at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
W/System.err:     at io.reactivex.Observable.subscribe(Observable.java:12036)
                  at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
                  at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:579)
                  at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
                  at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
                  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                  at java.lang.Thread.run(Thread.java:761)


W/System.err: Caused by: java.io.EOFException: \n not found: limit=0 content=…
W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:236)
                  at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
                  at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
                ... 29 more
我一直在看,阅读教程,以确保我构建的API和连接代码正确,并阅读其他人有同样的问题,并做他们所做的没有解决我的问题

这是我的node.js代码:

var postData = req.body; // get post params
       var userId = uid.v4();
       const userExistQuery = 'SELECT email, first_name, last_name FROM User WHERE email = @email AND category = @category AND password = @password';
    if(postData.category.valueOf() == new String("Seller").valueOf()){
        connection.request()
        .input('email', sql.VarChar(45), postData.email)
        .input('password', sql.VarChar(45), postData.password)
        .input('category', sql.VarChar(45), postData.category)
             .query(userExistQuery)
             .then((recordSet)=>{
             if(recordSet.rowsAffected == 1){
                res.json("Already registered as Seller.");
              }else{
                var streetNum = postData.streetNum;
                var buildingNum = postData.buildingNum;
                var apartmentNum = postData.apartmentNum;
                var town = postData.town;
                var governance = postData.governance;
                var floorNum = postData.floorNum;
                var poBox = postData.poBox;
                var zipCode = postData.zipCode;
                var creditInfo = postData.creditInfo;
                const addSellerQuery =
                'INSERT INTO Seller(seller_id, street#, building#, apartment#, town, governance, floor#, P.O_box, zip_code, credit_info, first_name, last_name, email, password, phone_number ,category) VALUES(@sellerId,@streetNum,@buildingNum,@apartmentNum,@town,@governance,@floorNum,@poBox,@zipCode,@creditInfo,@firstName,@lastName,@email,@password, @phoneNumber, @category)';
 connection.request()
 .input('sellerId', sql.VarChar(45), userId)
 .input('streetNum', sql.VarChar(45), postData.streetNum)
 .input('buildingNum', sql.VarChar(45), postData.buildingNum)
 .input('apartmentNum', sql.VarChar(45), postData.apartmentNum)
 .input('town', sql.VarChar(45), postData.town)
 .input('governance', sql.VarChar(45), postData.governance)
 .input('floorNum', sql.VarChar(45), postData.floorNum)
 .input('poBox', sql.VarChar(45), postData.poBox)
 .input('zipCode', sql.VarChar(45), postData.zipCode)
 .input('creditInfo', sql.VarChar(45), postData.creditInfo)
 .input('firstName', sql.VarChar(45), postData.firstName)
 .input('lastName', sql.VarChar(45), postData.lastName)
 .input('email', sql.VarChar(45), postData.email)
 .input('password', sql.VarChar(45), postData.password)
 .input('phoneNumber', sql.VarChar(45), postData.phoneNumber)
 .input('category', sql.VarChar(45), postData.category)
.query(addSellerQuery)
.then((recordAdded)=>{
  if(recordAdded.rowsAffected == 1){
    res.json(dataPost.firstName + "Registered as Seller.");
  }else{
    res.json(dataPost.firstName + "failed to register as Seller.");
  }})}
这是我的改装代码:

public static Retrofit getRetrofit() {
    if (retrofit == null) {
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                .connectTimeout(120, TimeUnit.SECONDS)
                .readTimeout(120, TimeUnit.SECONDS)
                .writeTimeout(120, TimeUnit.SECONDS)
                .build();
        retrofit = new Retrofit.Builder()
                .baseUrl("http://10.0.2.2:1433/")
                .client(okHttpClient)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
   }
    return retrofit;
}
下面是我如何从api获取数据的代码:

 compositeSubs.add(myAPI.buyerSignUp(buyer.getEmail(), buyer.getName().split(" ")[0]
                        , buyer.getName().split(" ")[1], buyer.getPassword(), buyer.bringType(), buyer.getPhoneNumber())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(s -> {   // onNext method
                            Log.d(TAG, "onPreExecute get data from api");
                            ((AuthListener) callBack).onSignUp(s, compositeSubs, false);
                            Log.d(TAG, "onPreExecute after get data from api");
                        }, throwable -> {   // onError method
                            Log.d(TAG, "onPreExecute getting api error");
                            throwable.printStackTrace();
                        }, () -> {          // onComplete method
                            Log.d(TAG, "onPreExecute after getting data from api");
                            Handler handler = new Handler(Looper.getMainLooper());
                            handler.post(() -> {
                                if (progressDialog.isShowing())
                                    progressDialog.dismiss();
                            });
                            Log.d(TAG, "completed");
                        }));

我希望看到新买家被添加到我数据库中的买家表中,但此异常阻止添加新买家。

您尝试过这里的解决方案吗?

没有人不工作,还有谁发布了未使用改装的问题。