0
我从改造,我想实现的错误处理,特别是连接超时产生可观察到的。在错误的用户会被调用得很好,但应用程序仍用了socketTimeout错误崩溃。有什么建议?rxJava错误捕获socketTimeoutException
Observable<History> history = api.returnHistoryRX(pair, String.valueOf(unixTime-3600), String.valueOf(unixTime));
history.onErrorReturn(throwable -> null);
用户
public void getPriceNow(Observable<List<history>> history, String pair) {
Timestamp timestamp2;
timestamp2 = new Timestamp(System.currentTimeMillis());
history.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(history1 -> {
String currentValue;
if (history1.size()>0){
System.out.println("testing rx");
}
}, e->System.out.println("getPriceNow: error called"));
}
来测试我的超时设置的东西与okhttp
private OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.MILLISECONDS)
.readTimeout(30L, TimeUnit.MILLISECONDS)
.writeTimeout(100L, TimeUnit.MILLISECONDS);
错误链看起来像这样不合理的低:
的java.lang。 IllegalStateException:在Scheduler.Worker线程上抛出异常。添加onError
处理。
产生的原因:rx.exceptions.OnErrorNotImplementedException:连接失败
产生的原因:java.net.SocketTimeoutException:连接失败
这是100%正确的。我居然发现了坠毁没有发生由于这些要求,但其他地方的应用进行相同的调用。我删除了位后导致崩溃我仍然有onErrorReturn的问题没有发射过,使这一更新修复完全。没有这个,我可能会一直盯着几个小时,所以谢谢你! – massphoenix