简体   繁体   English

Robospice发送改造请求3次

[英]Robospice sends Retrofit the same request 3 times

I'm using Robospice with Retrofit module just like in sample. 我在示例中将Robospice与Retrofit模块一起使用。 I'm sending a POST request with body data. 我正在发送带有正文数据的POST请求。

When request returns 200, it's ok. 当请求返回200时,就可以了。

But when it returns for example error 403, I see it is executing 3 times! 但是当它返回例如错误403时,我看到它正在执行3次! onRequestFailure callback receives the control only after the last request execution. onRequestFailure回调仅在上一次请求执行后才接收控件。

And log tells that loadDataFromNetwork() method from RetrofitSpiceRequest's descendant class is called 3 times too. 日志告诉我们RetrofitSpiceRequest的后代类的loadDataFromNetwork()方法也被调用了3次。

How can I avoid this strange behavior? 如何避免这种奇怪的行为?

It's called "retry policy". 这称为“重试策略”。

How can I setup a retry policy for failed requests ? 如何为失败的请求设置重试策略?

Use spiceRequest.setRetryPolicy(). 使用spiceRequest.setRetryPolicy()。 By default, requests have a DefaultRetryPolicy . 默认情况下,请求具有DefaultRetryPolicy It will be activated when a network request fails. 当网络请求失败时,它将被激活。

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM