Volley.NoConnectionError: java.io.EOFException 0

I don't understand this error, although I am on the net many times, but doing nothing, the error appears somewhere. I made an application that uses the VOlley library and everything works well, 95% of my request works, but someday I have an error;

11-12 12:18:54.991: I/Error(1870): com.android.volley.NoConnectionError: java.io.EOFException 0

      

and I don't know why this error appears. Example during y COnnection to app, I send somes information like register_id to receive GCM notification, login, password and imei, and sometime I have this error that appears 0_0

This is my login request (but in my entire request that I have this error):

 public void connectDriver() {

    String url = UtilClass.getSytemValue("url_proxy",LoginConnection.this)+ ":"+ UtilClass.getSytemValue("port_proxy",LoginConnection.this) + "/api/driver/login";

        final ProgressDialog pDialog = new ProgressDialog(this);
        pDialog.setMessage("Connexion...");
        pDialog.show();
        Log.i("url", url);

        RequestQueue rq = Volley.newRequestQueue(this);
        StringRequest postReq = new StringRequest(Request.Method.POST, url,
            new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                Log.d("response connection ", response);

                pDialog.dismiss();

                Gson gson = new Gson();
                final Driver driver = gson.fromJson(response.toString(), Driver.class);
                Log.i("DRIVER GSON", driver.toString());
                UtilClass.setSytemValue("driver_id",Integer.toString(driver.getId()),LoginConnection.this);

                driver.setLogin(mlogin);
                driver.setPass(util.md5(mPassword));

                if (driver.getSignature().isEmpty()) {
                    driver.setSignature(null);
                }

                final DriverQuery driverQuery = new DriverQuery(LoginConnection.this);
                driverQuery.open();
                long success = driverQuery.insertDriver(driver);
                driverQuery.close();
                Log.i("connection driver success : ",Long.toString(success));

                UtilClass.setSytemValue("driver_id",Integer.toString(driver.getId()),LoginConnection.this);
                Log.i("DRIVER SEND BEFORE GOTO", driver.toString());
                goTo(driver);

            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                pDialog.dismiss();
                int errorStatus = error.networkResponse != null ? error.networkResponse.statusCode
                        : 0;
                Log.i("Error ", error.toString() + " "
                        + errorStatus);

                AppController.getInstance().getRequestQueue()
                .stop();

                DriverQuery driverQuery = new DriverQuery(LoginConnection.this);
                driverQuery.open();
                Driver driver = driverQuery.getDriverExist(mlogin,util.md5(mPassword));

                if (driver.getId() != 0) {
                    goTo(driver);
                    UtilClass.setSytemValue("driver_id",Integer.toString(driver.getId()),LoginConnection.this);

                } else if (errorStatus == 500) {

                    AlertDialog ad = new AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton("Ok", null)
                    .setTitle("Problème")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage("Un problème est survenue sur le serveur\nSi cela persiste , veuillez contacter l'administrateur")
                    .create();
                    ad.show();

                } else if (errorStatus == 400) {

                    AlertDialog ad = new AlertDialog.Builder(
                            LoginConnection.this)
                    .setPositiveButton("Ok", null)
                    .setTitle("Erreur")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage("La syntaxe de la requête est erronée.\nSi cela persiste , veuillez contacter l'administrateur")
                    .create();
                    ad.show();

                } else if (errorStatus == 404) {

                    AlertDialog ad = new AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton("Ok", null)
                    .setTitle("Erreur")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage("Identification incorrect.\nSi cela persiste , veuillez contacter l'administrateur")
                    .create();
                    ad.show();

                } else if (errorStatus == 0) {

                    AlertDialog ad = new AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton("Ok", null)
                    .setTitle("Erreur")
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage("Le temps d'attente a été dépassé.\nSi cela persiste , veuillez contacter l'administrateur")
                    .create();
                    ad.show();

                }
                driverQuery.close();
            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                Map<String, String> params = new HashMap<String, String>();

                params.put("login", mlogin);
                params.put("password", util.md5(mPassword));
                params.put("imei", getImei());
                params.put("registerId", UtilClass.getSytemValue("register_id", LoginConnection.this));

                Log.i("getParams", params.toString());
                return checkParams(params);
            }
              private Map<String, String> checkParams(Map<String, String> map){               
                    Iterator<Entry<String, String>> it = map.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry<String, String> pairs = (Map.Entry<String, String>)it.next();
                        if(pairs.getValue()==null){
                            map.put(pairs.getKey(), "");
                        }
                    }
                    return map;             
                }

        };

        // Adding request to request queue
        postReq.setRetryPolicy(new DefaultRetryPolicy(60 * 1000, 1,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));       
        AppController.getInstance().addToAndStartRequestQueue(postReq);         
        Log.i(TAG + " -> cache volley",Integer.toString(rq.getSequenceNumber()));


}

      

+3


source to share


2 answers


This happened due to the simultaneous call of several requests. I have given priority and it works fine.

@Override
public Priority getPriority() {
    Request.Priority mPriority = Priority.HIGH;
    return mPriority;
}

      



Note . Set different priorities according to their needs.

+2


source


Encode the url before making the StringRequest to volleyball. Or encode only the end of request parameter.



0


source







All Articles