【发布时间】:2018-09-13 14:14:33
【问题描述】:
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();
【问题讨论】:
-
检查您的服务器,请您再试一次。
-
@HimeshGoswami 在 iOS 中运行良好
-
您使用的是模拟器还是物理设备?
-
@MohammadTabbara 我正在使用物理设备
-
@shiva 你要尝试在这个 api 中发送图像吗?
标签: android post web service okhttp