使用RxAndroid和改造

时间:2018-12-25 16:23:14

标签: android node.js retrofit2 rx-android

我正在使用mysql数据库在Android项目上工作,并在Node.Js上执行后端,我有一种方法可以通过将数据通过JSON文件发送到android应用来创建新用户: 此代码用于改造实例化:

retrofit = new Retrofit.Builder()
                .baseUrl("https://ipAddress:port/")
                .addConverterFactory(ScalarsConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();

此代码用于与node.js进行通信:

Buyer buyer = (Buyer) user;
                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
                            if (s.equals("false")) {
                                ((AuthListener) callBack).onSignUp(s, false);
                            } else if (s.equals("true")) {
                                ((AuthListener) callBack).onSignUp(s, true);
                            } else {
                                ((AuthListener) callBack).onSignUp(s, false);
                            }
                        }, throwable -> {   // onError method
                            Log.e(TAG, throwable.getMessage(), throwable);
                        }, () -> {          // onComplete method
                            Log.d(TAG, "completed");
                        }));

这是我得到的例外:

  • 握手失败               javax.net.ssl.SSLHandshakeException:握手失败                   在com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:423)                   在okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:281)                   在okhttp3.internal.connection.RealConnection。EstablishmentProtocol(RealConnection.java:251)                   在okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)                   在okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)                   在okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)                   在okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)                   在okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)                   在okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)                   在okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)                   在okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)                   在okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)                   在okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)                   在okhttp3.RealCall.execute(RealCall.java:69)                   在retrofit2.OkHttpCall.execute(OkHttpCall.java:180)                   在retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:41)                   在io.reactivex.Observable.subscribe(Observable.java:12036)                   在retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)                   在io.reactivex.Observable.subscribe(Observable.java:12036)                   在io.reactivex.internal.operators.observable.ObservableSubscribeOn $ SubscribeTask.run(ObservableSubscribeOn.java:96)                   在io.reactivex.Scheduler $ DisposeTask.run(Scheduler.java:579)                   在io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)                   在io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)                   在java.util.concurrent.FutureTask.run(FutureTask.java:266)                   在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)                   在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)                   在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:636)                   在java.lang.Thread.run(Thread.java:764)                引起原因:javax.net.ssl.SSLProtocolException:SSL握手中止:ssl = 0x8f76da40:SSL库失败,通常是协议错误               错误:100000f7:SSL例程:OPENSSL_internal:WRONG_VERSION_NUMBER(external / boringssl / src / ssl / tls_record.c:235 0x9f174e9f:0x00000000)                   在com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(本机方法)                   在com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:351)                     ...另外33个

为什么此错误持续显示,如何处理以及如何解决?

0 个答案:

没有答案