Android 改装OkHttp连接在1.5分钟后失败~
我在后台运行了一个服务,作为开始,它获取用户位置并将其发送到我的服务器 问题是当应用程序关闭时,服务运行良好。但是在1.5分钟后,我得到了Android 改装OkHttp连接在1.5分钟后失败~,android,retrofit2,okhttp3,Android,Retrofit2,Okhttp3,我在后台运行了一个服务,作为开始,它获取用户位置并将其发送到我的服务器 问题是当应用程序关闭时,服务运行良好。但是在1.5分钟后,我得到了java.net.ConnectException:无缘无故连接到/10.0.0.14:2525,我无法检测到为什么会发生这种情况 我在小米Redme Not2上运行它,并打开所有安全许可证 对不起,这是一个很长的问题。但是我试着调试下面所有的类,不知道出了什么问题。没有对象是空的或类似的 这是我的日志: java.net.ConnectException:
java.net.ConnectException:无缘无故连接到/10.0.0.14:2525
,我无法检测到为什么会发生这种情况
我在小米Redme Not2上运行它,并打开所有安全许可证
对不起,这是一个很长的问题。但是我试着调试下面所有的类,不知道出了什么问题。没有对象是空的或类似的
这是我的日志:
java.net.ConnectException: Failed to connect to /10.0.0.14:2525
at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:139)
at okhttp3.internal.io.RealConnection.connect(RealConnection.java:108)
at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:188)
at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:127)
at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)
at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:273)
at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:215)
at okhttp3.RealCall.getResponse(RealCall.java:241)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:199)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:203)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:188)
at **com.smartbus.backend.RestProvider.lambda$buildClient$1(RestProvider.java:84)**
at com.smartbus.backend.RestProvider$$Lambda$2.intercept(Unknown Source)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:188)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:161)
at okhttp3.RealCall.execute(RealCall.java:57)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:118)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:86)
at **com.smartbus.utils.network.SynchronousRetrofitCall.execute(SynchronousRetrofitCall.java:27)
at com.smartbus.utils.tasks.PrepareRestApiTask.doInBackground(PrepareRestApiTask.java:43)
at com.smartbus.utils.tasks.PrepareRestApiTask.doInBackground(PrepareRestApiTask.java:24)**
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
异常可能会在com.smartbus.utils.network.synchronousRefundationCall.execute(synchronousRefundationCall.java:27)中引发。
这是相关的课程
@AllArgsConstructor
public class SynchronousRetrofitCall<T> {
private final Call<T> mServiceCall;
public Optional<Response<T>> execute() {
try {
return Optional.of(mServiceCall.execute());
} catch (IOException|JsonSyntaxException e) {
e.printStackTrace();
return Optional.absent();
}
}
}
这是PrepareRestApiTask类:
@SuppressWarnings("Guava")
@RequiredArgsConstructor
public class PrepareRestApiTask<responseObject> extends AsyncTask<Void, Void, Optional<Response<RestResponse<responseObject>>>> {
private static final String TAG = "restApi";
private final restApiCaller<responseObject> caller;
public static Optional<String> connectToRestServer() {
return Optional.fromNullable(LocalStore.getToken());
}
@Override
protected Optional<Response<RestResponse<responseObject>>> doInBackground(Void... voids) {
Optional<String> hashedToken = connectToRestServer();
if (!hashedToken.isPresent()) {
cancel(false);
return null;
}
SmartbusClient client = RestProvider.createService(SmartbusClient.class);
/////!!!this is the relevant line!!!//////
return new SynchronousRetrofitCall<>(caller.onRestApiReadyBackgroundRun(hashedToken.get(), client)).execute();
}
@Override
protected void onPostExecute(Optional<Response<RestResponse<responseObject>>> responseOptional) {
if (!responseOptional.isPresent()) {
return;
}
if (responseOptional.get().isSuccess() && responseOptional.get().body().isOk())
caller.onEverythingFinishedUIThreadRun(responseOptional.get().body().data);
else {
if (responseOptional.get().isSuccess()) {
Log.e(TAG, "error connecting to restApi: " + responseOptional.get().body().error);
} else {
try {
Log.e(TAG, "error connecting to restApi: " + responseOptional.get().errorBody().string());
} catch (IOException e) {
e.printStackTrace();
}
}
caller.onError(responseOptional.get());
}
}
@Override
protected void onCancelled(Optional<Response<RestResponse<responseObject>>> responseOptional) {
}
@Override
protected void onCancelled() {
onCancelled(null);
}
public interface restApiCaller<responseObject> {
Call<RestResponse<responseObject>> onRestApiReadyBackgroundRun(String hashedToken, SmartbusClient client);
void onEverythingFinishedUIThreadRun(responseObject theData);
void onError(Response<RestResponse<responseObject>> response);
}
}
@SuppressWarnings(“番石榴”)
@所需参数构造函数
公共类PrepareRestApiTask扩展异步任务{
私有静态最终字符串TAG=“restApi”;
私人最终主叫人;
公共静态可选connectToRestServer(){
返回可选的.fromNullable(LocalStore.getToken());
}
@凌驾
受保护的可选doInBackground(无效…无效){
可选hashedToken=connectToRestServer();
如果(!hashedToken.isPresent()){
取消(假);
返回null;
}
SmartbusClient=RestProvider.createService(SmartbusClient.class);
/////!!!这是相关线路//////
返回新的SynchronousRefughtCall(caller.onRestApiReadyBackgroundRun(hashedToken.get(),client)).execute();
}
@凌驾
PostExecute上受保护的void(可选响应选项){
如果(!responseOptional.isPresent()){
返回;
}
if(responseOptional.get().issucess()&&responseOptional.get().body().isOk())
caller.onEverythingFinishedUIThreadRun(responseOptional.get().body().data);
否则{
if(responseOptional.get().issucess()){
Log.e(标记“连接到restApi时出错:”+responseOptional.get().body().error);
}否则{
试一试{
Log.e(标记“连接到restApi时出错:”+responseOptional.get().errorBody().string());
}捕获(IOE异常){
e、 printStackTrace();
}
}
caller.onError(responseOptional.get());
}
}
@凌驾
取消时受保护的无效(可选响应可选){
}
@凌驾
受保护的void onCancelled(){
一次取消(空);
}
公共接口重启器{
调用RestapiReadyBackgroundRun(字符串散列,SmartbusClient客户端);
使用READRUN(响应对象数据)使所有完成的数据无效;
无效单错误(响应);
}
}
这就是服务:
public class GpsService extends Service
implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener,
LocationListener {
public static final String TAG_PRIORITY = "priority";
public static final int PRIORITY_LISTEN_ONLY = 1;
public static final int PRIORITY_PERFECT = 2;
public static final int PRIORITY_BALANCED = 3;
public static final String TAG_STOP_ON_FIRST_LOCATION = "stop_first_location";
public static final String TAG_RETURN_TO_LISTEN_MODE = "return_to_listen_mode";
private static final String TAG = "GpsService";
private static final long INTERVAL_TIME_LISTEN_MS = 1000 * 60 * 10;
private static final long INTERVAL_TIME_BALANCED_MS = 1000 * 30;
private static final long INTERVAL_TIME_PERFECT_MS = 1000 * 5;
private static final float ACCURACY_METERS = 60f;
public static final int REQUEST_CHECK_SETTINGS = 4359;
private static LogUtils logUtils = new LogUtils(TAG);
private CalendarRide currentRide;
private int timeToResetGps = 1000 * 60 * 30;
static {
logUtils.setActive(false);
}
private GoogleApiClient mGoogleApiClient;
// @Getter private static GpsService instance = null;
private int priority;
private boolean shouldStop = false;
String mUsername;
int mDeviceId;
Date lastTalkToServer;
static List<GpsCallback> callbacks = new ArrayList<>();
public GpsService() {
super();
logUtils.logFunctionCalled();
}
@Nullable @Override public IBinder onBind(Intent intent) {
logUtils.logFunctionCalled();
return null;
}
@Override public void onCreate() {
super.onCreate();
logUtils.logFunctionCalled();
lastTalkToServer = new Date(0);
mUsername = LocalStore.getUsername();
if (mUsername == null) {
try {
mUsername = User.getCurrentUser().username;
} catch (NullPointerException e) {
stopSelf();
}
}
mDeviceId = FirebasePhoneIdService.getDeviceId();
// instance = this;
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
if (LocalStore.getToken() == null) stopSelf();
logUtils.logFunctionOut();
}
@Override public int onStartCommand(Intent intent, int flags, int startId) {
logUtils.logFunctionCalled();
priority = intent.getIntExtra(TAG_PRIORITY, PRIORITY_LISTEN_ONLY);
shouldStop = intent.getBooleanExtra(TAG_STOP_ON_FIRST_LOCATION, false);
logUtils.custom(
"priority: " + priority + " PRIORITY_LISTEN: " + LocationRequest.PRIORITY_NO_POWER);
if (mGoogleApiClient.isConnected()) {
disconnectLocations();
}
mGoogleApiClient.connect();
logUtils.logFunctionOut();
return START_STICKY;
}
@Override public void onConnected(@Nullable Bundle bundle) {
logUtils.logFunctionCalled();
LocationRequest req = LocationRequest.create();
req.setFastestInterval(0);
req.setSmallestDisplacement(0f);
switch (priority) {
case PRIORITY_BALANCED:
req.setInterval(INTERVAL_TIME_BALANCED_MS);
req.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
break;
case PRIORITY_PERFECT:
req.setInterval(INTERVAL_TIME_PERFECT_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
break;
case PRIORITY_LISTEN_ONLY:
default:
req.setInterval(INTERVAL_TIME_LISTEN_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
checkIfRequestIsValidAndStartGps(req);
}
@Override public void onConnectionSuspended(int i) {
Log.e(TAG, "google connection suspended");
}
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d(TAG, "google connection failed");
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
}
@Override public void onLocationChanged(Location location) {
// logUtils.custom("onLocationChanged: " + location.getLongitude()+"---"+location.getLatitude()+" accuracy:"+location.getAccuracy());
//if (location.hasAccuracy() && location.getAccuracy() <= ACCURACY_METERS) {
// found a good location
onGoodLocationFound(location);
currentRide = CalendarRide.getCurrentRideForGps();
if (currentRide != null){
checkIfNeedToReturnGpsToListenMode();
}
//}
// float[] distance = new float[1];
// Location.distanceBetween(location.getLatitude(), location.getLongitude(), 31.7568686, 35.2016888,distance);
// float resultse = distance[0];
}
private void checkIfNeedToReturnGpsToListenMode() {
Date now = Calendar.getInstance().getTime();
Date rideEndTime = currentRide.getEndTime();
if (now.getTime() - rideEndTime.getTime() >= timeToResetGps ){
CalendarRide.setCurrentRideForGps(null);
LocationRequest req = LocationRequest.create();
req.setInterval(INTERVAL_TIME_LISTEN_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
checkIfRequestIsValidAndStartGps(req);
}
}
private void onGoodLocationFound(Location location) {
tellTheServer(location);
if (shouldStop) {
restartSilentMode();
}
for (Iterator<GpsCallback> callbackIterator = callbacks.iterator();
callbackIterator.hasNext(); ) {
GpsCallback callback = callbackIterator.next();
boolean shouldContinue = callback.onGoodLocationFound(location);
if (!shouldContinue) callbackIterator.remove();
}
}
.....
private void tellTheServer(Location location) {
if (talkedToServerRecently()) return;
logUtils.custom("starting communication with server");
if (mDeviceId == -1) { // can't update the server
mDeviceId =
LocalStore.getDeviceId(); // better luck next time (meanwhile maybe the user has connected)
return;
}
new PrepareRestApiTask<>(new PrepareRestApiTask.restApiCaller<String>() {
@Override public Call<RestResponse<String>> onRestApiReadyBackgroundRun(String hashedToken,
SmartbusClient client) {
DriverPlaceUpdate newPlace =
new DriverPlaceUpdate(location.getLatitude(), location.getLongitude(), location.getSpeed()*3.6);
return client.update_driver_location(newPlace, hashedToken);
// return client.update_driver_location(mUsername, mDeviceId, newPlace, hashedToken);
}
@Override public void onEverythingFinishedUIThreadRun(String theData) {
Log.d(TAG, "server response went well");
lastTalkToServer = new Date();
}
@Override public void onError(Response<RestResponse<String>> response) {
if (response == null) return;
mDeviceId =
LocalStore.getDeviceId(); // if the problem is that there is no device, initTask it
try {
Log.e(TAG, response.errorBody().string());
} catch (IOException e) {
e.printStackTrace();
try {
Log.e(TAG, response.body().error);
} catch (NullPointerException ignore) {
}
}
}
}).execute();
}
公共类GpsService扩展服务
实现GoogleAppClient.ConnectionCallbacks、GoogleAppClient.OnConnectionFailedListener、,
位置侦听器{
公共静态最终字符串标记\u PRIORITY=“PRIORITY”;
公共静态最终int优先级\u仅侦听\u=1;
公共静态最终int优先级_PERFECT=2;
公共静态最终int优先级_平衡=3;
public static final String TAG_STOP_ON_FIRST_LOCATION=“STOP_FIRST_LOCATION”;
公共静态最终字符串标记\u RETURN\u TO\u LISTEN\u MODE=“RETURN\u TO\u LISTEN\u MODE”;
私有静态最终字符串TAG=“GpsService”;
私有静态最终长间隔\u时间\u监听\u MS=1000*60*10;
专用静态最终长间隔时间平衡毫秒=1000*30;
私有静态最终长间隔时间完美毫秒=1000*5;
专用静态最终浮子精度\u米=60f;
公共静态最终整数请求检查设置=4359;
私有静态LogUtils LogUtils=新的LogUtils(标记);
私家车;
专用int timeToResetGps=1000*60*30;
静止的{
logUtils.setActive(false);
}
私人GoogleapClient MGoogleapClient;
//@Getter private静态GpsService instance=null;
私人优先权;
私有布尔值shouldStop=false;
弦乐博物馆名称;
int-mDeviceId;
日期lastTalkToServer;
静态列表回调=new ArrayList();
公共GpsService(){
超级();
logUtils.logFunctionCalled();
}
@Nullable@Override public IBinder onBind(意图){
logUtils.logFunctionCalled();
返回null;
}
@重写公共void onCreate(){
super.onCreate();
logUtils.logFunctionCalled();
lastTalkToServer=新日期(0);
mUsername=LocalStore.getUsername();
if(mUsername==null){
试一试{
mUsername=User.getCurrentUser().username;
}捕获(NullPointerException e){
stopSelf();
}
}
mDeviceId=FirebasePhoneIdService.getDeviceId();
//实例=此;
mGoogleApiClient=new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(此)
.addApi(LocationServices.API)
.build();
if(LocalStore.getToken()==null)stopSelf();
logUtils.logFunctionOut();
}
@覆盖公共int onStartCommand(Intent Intent、int标志、int startId){
logUtils.logFunctionCalled();
priority=intent.getIntExtra(标记优先级,优先级仅限于侦听);
shouldStop=intent.getBooleanExtra(在第一个位置上标记\u STOP\u,false);
logUtils.custom(
“优先级:”+优先级+“优先级\侦听:”+位置请求。优先级\无电源);
if(mgoogleapClient.isConnected()){
断开位置();
}
mGoogleApiClient.connect();
logUtils.logFunctionOut();
返回开始时间;
}
@覆盖已连接的公共无效(@Nullable Bundle){
logUtils.logFunctionCalled();
LocationRequest req=LocationRequest.create();
请求setFastTestInterval(0);
要求设置最小位移(0f);
交换机(优先级){
案件优先权平衡:
要求设置间隔(间隔时间平衡毫秒);
要求设置优先级(位置请求、优先级、平衡功率、精度);
打破
案件优先权:
请求设置间隔(间隔_
public class GpsService extends Service
implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener,
LocationListener {
public static final String TAG_PRIORITY = "priority";
public static final int PRIORITY_LISTEN_ONLY = 1;
public static final int PRIORITY_PERFECT = 2;
public static final int PRIORITY_BALANCED = 3;
public static final String TAG_STOP_ON_FIRST_LOCATION = "stop_first_location";
public static final String TAG_RETURN_TO_LISTEN_MODE = "return_to_listen_mode";
private static final String TAG = "GpsService";
private static final long INTERVAL_TIME_LISTEN_MS = 1000 * 60 * 10;
private static final long INTERVAL_TIME_BALANCED_MS = 1000 * 30;
private static final long INTERVAL_TIME_PERFECT_MS = 1000 * 5;
private static final float ACCURACY_METERS = 60f;
public static final int REQUEST_CHECK_SETTINGS = 4359;
private static LogUtils logUtils = new LogUtils(TAG);
private CalendarRide currentRide;
private int timeToResetGps = 1000 * 60 * 30;
static {
logUtils.setActive(false);
}
private GoogleApiClient mGoogleApiClient;
// @Getter private static GpsService instance = null;
private int priority;
private boolean shouldStop = false;
String mUsername;
int mDeviceId;
Date lastTalkToServer;
static List<GpsCallback> callbacks = new ArrayList<>();
public GpsService() {
super();
logUtils.logFunctionCalled();
}
@Nullable @Override public IBinder onBind(Intent intent) {
logUtils.logFunctionCalled();
return null;
}
@Override public void onCreate() {
super.onCreate();
logUtils.logFunctionCalled();
lastTalkToServer = new Date(0);
mUsername = LocalStore.getUsername();
if (mUsername == null) {
try {
mUsername = User.getCurrentUser().username;
} catch (NullPointerException e) {
stopSelf();
}
}
mDeviceId = FirebasePhoneIdService.getDeviceId();
// instance = this;
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
if (LocalStore.getToken() == null) stopSelf();
logUtils.logFunctionOut();
}
@Override public int onStartCommand(Intent intent, int flags, int startId) {
logUtils.logFunctionCalled();
priority = intent.getIntExtra(TAG_PRIORITY, PRIORITY_LISTEN_ONLY);
shouldStop = intent.getBooleanExtra(TAG_STOP_ON_FIRST_LOCATION, false);
logUtils.custom(
"priority: " + priority + " PRIORITY_LISTEN: " + LocationRequest.PRIORITY_NO_POWER);
if (mGoogleApiClient.isConnected()) {
disconnectLocations();
}
mGoogleApiClient.connect();
logUtils.logFunctionOut();
return START_STICKY;
}
@Override public void onConnected(@Nullable Bundle bundle) {
logUtils.logFunctionCalled();
LocationRequest req = LocationRequest.create();
req.setFastestInterval(0);
req.setSmallestDisplacement(0f);
switch (priority) {
case PRIORITY_BALANCED:
req.setInterval(INTERVAL_TIME_BALANCED_MS);
req.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
break;
case PRIORITY_PERFECT:
req.setInterval(INTERVAL_TIME_PERFECT_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
break;
case PRIORITY_LISTEN_ONLY:
default:
req.setInterval(INTERVAL_TIME_LISTEN_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
checkIfRequestIsValidAndStartGps(req);
}
@Override public void onConnectionSuspended(int i) {
Log.e(TAG, "google connection suspended");
}
@Override public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d(TAG, "google connection failed");
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
}
@Override public void onLocationChanged(Location location) {
// logUtils.custom("onLocationChanged: " + location.getLongitude()+"---"+location.getLatitude()+" accuracy:"+location.getAccuracy());
//if (location.hasAccuracy() && location.getAccuracy() <= ACCURACY_METERS) {
// found a good location
onGoodLocationFound(location);
currentRide = CalendarRide.getCurrentRideForGps();
if (currentRide != null){
checkIfNeedToReturnGpsToListenMode();
}
//}
// float[] distance = new float[1];
// Location.distanceBetween(location.getLatitude(), location.getLongitude(), 31.7568686, 35.2016888,distance);
// float resultse = distance[0];
}
private void checkIfNeedToReturnGpsToListenMode() {
Date now = Calendar.getInstance().getTime();
Date rideEndTime = currentRide.getEndTime();
if (now.getTime() - rideEndTime.getTime() >= timeToResetGps ){
CalendarRide.setCurrentRideForGps(null);
LocationRequest req = LocationRequest.create();
req.setInterval(INTERVAL_TIME_LISTEN_MS);
req.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
checkIfRequestIsValidAndStartGps(req);
}
}
private void onGoodLocationFound(Location location) {
tellTheServer(location);
if (shouldStop) {
restartSilentMode();
}
for (Iterator<GpsCallback> callbackIterator = callbacks.iterator();
callbackIterator.hasNext(); ) {
GpsCallback callback = callbackIterator.next();
boolean shouldContinue = callback.onGoodLocationFound(location);
if (!shouldContinue) callbackIterator.remove();
}
}
.....
private void tellTheServer(Location location) {
if (talkedToServerRecently()) return;
logUtils.custom("starting communication with server");
if (mDeviceId == -1) { // can't update the server
mDeviceId =
LocalStore.getDeviceId(); // better luck next time (meanwhile maybe the user has connected)
return;
}
new PrepareRestApiTask<>(new PrepareRestApiTask.restApiCaller<String>() {
@Override public Call<RestResponse<String>> onRestApiReadyBackgroundRun(String hashedToken,
SmartbusClient client) {
DriverPlaceUpdate newPlace =
new DriverPlaceUpdate(location.getLatitude(), location.getLongitude(), location.getSpeed()*3.6);
return client.update_driver_location(newPlace, hashedToken);
// return client.update_driver_location(mUsername, mDeviceId, newPlace, hashedToken);
}
@Override public void onEverythingFinishedUIThreadRun(String theData) {
Log.d(TAG, "server response went well");
lastTalkToServer = new Date();
}
@Override public void onError(Response<RestResponse<String>> response) {
if (response == null) return;
mDeviceId =
LocalStore.getDeviceId(); // if the problem is that there is no device, initTask it
try {
Log.e(TAG, response.errorBody().string());
} catch (IOException e) {
e.printStackTrace();
try {
Log.e(TAG, response.body().error);
} catch (NullPointerException ignore) {
}
}
}
}).execute();
}