2017-10-03 6 views
-3

안녕하세요 안드로이드에서 Networking 용 Volley를 사용하고 있습니다. 모든 것이 문제가 있습니다. 인터넷 오류가 발생하여 시간이 초과되었지만 서버로 전송 된 요청이 처리되는 시간이 얼마 남지 않았습니다. 누군가 나를 도울 수 있습니까? 시간 제한을 늘려 보았지만 도움이되지 않았습니다.Android Volley 느린 인터넷 문제

+0

보십시오이 https://stackoverflow.com/questions/21011279/android-volley-checking-internet-state – Ankita

+0

https://stackoverflow.com/questions/17094718/change-volley-timeout -duration – Vij

+0

안녕하세요 Ankita 귀하의 제안에 감사드립니다, 그 느린 인터넷 문제를 잡을 수 있지만 문제가 언젠가는 서버로 전송되고 있습니다. 가입의 경우에, 나는 느린 인터넷 연결을 보이고 있지만 사용자가 추가됩니다. 데이터 베이스. – Shanmugam

답변

0

서버 데이터베이스에 쓸 수 있으면 시간이 초과 된 후에도 응답을받을 수 있습니다. onResposne과 onErrorResponse 메소드 모두에 로그를 넣으십시오.

JsonObjectRequest myRequest = new JsonObjectRequest(Method.GET, 
      url, null, 
      new Response.Listener<JSONObject>() { 

       @Override 
       public void onResponse(JSONObject response) { 
        Log.d(TAG, response.toString()); 
       } 
      }, new Response.ErrorListener() { 

       @Override 
       public void onErrorResponse(VolleyError error) { 
        Log.d(TAG, "Error: " + error.getMessage()); 
       } 
    }); 
0
 @Override 
    public void onErrorResponse(VolleyError volleyError) { 
    String message = null; 
    if (volleyError instanceof NetworkError) { 
     message = "Cannot connect to Internet...Please check your connection!"; 
    } else if (volleyError instanceof ServerError) { 
     message = "The server could not be found. Please try again after some time!!"; 
    } else if (volleyError instanceof AuthFailureError) { 
     message = "Cannot connect to Internet...Please check your connection!"; 
    } else if (volleyError instanceof ParseError) { 
     message = "Parsing error! Please try again after some time!!"; 
    } else if (volleyError instanceof NoConnectionError) { 
     message = "Cannot connect to Internet...Please check your connection!"; 
    } else if (volleyError instanceof TimeoutError) { 
     message = "Connection TimeOut! Please check your internet connection."; 
    } 
}