Response{protocol=http/1.1, code=504, message=GATEWAY_TIMEOUT, url=https://************************}
我正在
code=504, message=GATEWAY_TIMEOUT
在Android中但同样的url在iOS中取得了成功
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(30*1000, TimeUnit.MILLISECONDS)
.readTimeout(30*1000, TimeUnit.MILLISECONDS)
.writeTimeout(30*1000, TimeUnit.MILLISECONDS)
.retryOnConnectionFailure(false)
.build();
Request request = new Request.Builder().url(urlStr).post(formBody)
.addHeader("Authorization", g.getTokenType() + " " + g.getAccessToken())
.addHeader("Content-type", "application/x-www-form-urlencoded")
try {
Response mResponse = client.newCall(request).execute();
String jsonString = mResponse.body().string();
答案 0 :(得分:0)
试试这个
<head>
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/animate.css@3.5.2/animate.min.css">
<!-- or -->
</head>
<h1 class="animated infinite fadeOut" id="day-msg"></h1>
答案 1 :(得分:0)
根据服务器速度时间要求,将超时时间设置为分钟。
试试这个: -
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.readTimeout(2, TimeUnit.MINUTES);
httpClient.connectTimeout(2, TimeUnit.MINUTES);
httpClient.writeTimeout(2, TimeUnit.MINUTES);
httpClient.addInterceptor(new Interceptor() {
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
Request original = chain.request();
Request.Builder builder = original.newBuilder();
builder.method(original.method(), original.body());
builder.header("Accept", "application/json");
if (TOKEN.length() > 0)
builder.header("Authorization", TOKEN);
return chain.proceed(builder.build());
}
});
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(interceptor);
OkHttpClient client = httpClient.build();
Gson gson = new GsonBuilder()
.setLenient()
.create();