翻新-后续请求过多:21 [英] Retrofit - Too many follow-up requests: 21

查看:841
本文介绍了翻新-后续请求过多:21的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用改造程序来发出请求.

I'm using retrofit to make requests.

我遇到以下错误:

java.net.ProtocolException:后续请求过多:21

java.net.ProtocolException: Too many follow-up requests: 21

代码如下:

private OkHttpClient httpClient;
private CookieManager cookieManager;

public <S> S createCookieService(Class<S> serviceClass) {
    httpClient.interceptors().clear();
    httpClient.setCookieHandler(cookieManager);
    Retrofit.Builder builder = new Retrofit
            .Builder()
            .client(httpClient)
            .baseUrl(url)
            .addConverterFactory(GsonConverterFactory.create());

    Retrofit retrofit = builder.client(httpClient).build();

    return retrofit.create(serviceClass);
}

然后我发出请求:

示例:

1)登录

 @POST("/login")
 Call<User> login();

2)一些请求:

@GET("/request")
Call<PojoPojo> getPojo();

我收到太多后续请求的错误消息:21.

And I'm getting this error too many follow-up requests: 21.

请帮助.

推荐答案

杰克·沃顿(Jake Wharton)写道:

Jake Wharton wrote:

当数量超过20时,会抛出该错误(由OkHttp而不是Retrofit抛出) 调用端点时重定向.通常,这表示重定向 在两个端点之间循环. Chrome和Firefox也会停止 在多次重定向之后加载请求,但请求失败.

This gets thrown (by OkHttp, not Retrofit) when there are more than 20 redirects when calling an endpoint. Usually this indicates a redirect cycle between two endpoints. Both Chrome and Firefox will also stop loading the request after this many redirects and fail the request.

您需要咨询您的服务器团队或端点文档以 确保您将正确的数据直接传递给端点 想打电话.在这里无需采取任何措施.

You need to consult with your server team or endpoint documentation to ensure you are passing the correct data directly to the endpoint you want to call. No action for Retrofit to take here.

其余的线程在那里: https://github.com/square/retrofit/issues/1561

And rest of the thread is there: https://github.com/square/retrofit/issues/1561

这篇关于翻新-后续请求过多:21的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆