改装电话:
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("BASE URL")
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(new OkClient(getOkHttpClient()))
.build();
依赖关系:
compile 'com.squareup.okhttp:okhttp:2.7.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
错误:
USER_ID = XXXX&安培; ITEM_ID = X&安培; item_quantity = 1&安培; ITEM_COST = XXXX&安培; pay_id =条纹&安培; process_fee = XXX&安培; TOTAL_COST = XXX&安培; is_nagotiation = 0&安培; negotiate_id =安培;提示= XXX&安培; card_id的= XXXX
09-07 11:45:08.628 23473-24373/com.bridgellc.bridge D/Retrofit: —>
END HTTP (177-byte body) 09-07 11:45:18.635
23473-24373/com.bridgellc.bridge D/Retrofit: —- ERROR http:XXXXXX
09-07 11:45:18.650 23473-24373/com.bridgellc.bridge D/Retrofit:
java.net.SocketTimeoutException
解决方法:
尝试为OkHttp2客户端设置超时.首先创建一个OkHttp2客户端,
OkHttpClient client = new OkHttpClient.Builder()
client.setConnectTimeout(5, TimeUnit.MINUTES);
client.setReadTimeout(5, TimeUnit.MINUTES);
.build();
然后将其添加为Retrofit的默认客户端
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("BASE_URL")
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(client).build();