且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

改装API调用收到"HTTP失败:java.io.IOException:已取消".

更新时间:2023-01-13 08:14:16

如果用户取消了请求,则会抛出该异常.使用RxJavaCallAdapterFactory时,如果在完成呼叫之前取消订阅,则会发生这种情况.因此,我想在进行呼叫之后的某个时候,您会执行subscription.unsubscribe()来取消基础请求.

That exception gets thrown if the request is cancelled by the user. When using RxJavaCallAdapterFactory this happens if the subscription is unsubscribed before the call can complete. So I guess at some point after you do the call you do subscription.unsubscribe() which cancels the underlying requests.