Volley.NoConnectionError:java.io.EOFException 0 [英] Volley.NoConnectionError : java.io.EOFException 0

查看:1299
本文介绍了Volley.NoConnectionError:java.io.EOFException 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我在th网上搜索很多很多的时间,我不明白这个错误,但没有做,错误出现的某个时候。
我没有用它凌空库的应用程序,所有工作得很好,我的要求的95%的工作,但有时我有错误;

  12月11日至12日:18:54.991:I /错误(1870):com.android.volley.NoConnectionError:java.io.EOFException 0

和我不知道为什么这个错误出现。例如Y接到应用程序中,我送萨姆信息,如REGISTER_ID通知GCM,登录名,密码和IMEI好,有时我有这样的错误,出现0_0

这是我的登录请求(但它在我的要求,我有这个错误):

 公共无效connectDriver(){    字符串URL = UtilClass.getSytemValue(url_proxy,LoginConnection.this)+:+ Uti​​lClass.getSytemValue(port_proxy,LoginConnection.this)+/ API /驱动器/登录;        最后ProgressDialog pDialog =新ProgressDialog(本);
        pDialog.setMessage(Connexion的......);
        pDialog.show();
        Log.i(URL,URL);        请求队列RQ = Volley.newRequestQueue(本);
        StringRequest postReq =新StringRequest(Request.Method.POST,网址,
            新Response.Listener<串GT;(){
            @覆盖
            公共无效onResponse(字符串响应){
                Log.d(回应连接,响应);                pDialog.dismiss();                GSON GSON =新GSON();
                最终驱动驱动程序= 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));                如果(driver.getSignature()。的isEmpty()){
                    driver.setSignature(NULL);
                }                最后DRIVERQUERY DRIVERQUERY =新DRIVERQUERY(LoginConnection.this);
                driverQuery.open();
                长期成功= driverQuery.insertDriver(驱动器);
                driverQuery.close();
                Log.i(连接成功驱动,Long.toString(成功));                UtilClass.setSytemValue(driver_id,Integer.toString(driver.getId()),LoginConnection.this);
                Log.i(驱动程序前发送GOTO,driver.toString());
                GOTO(驱动器);            }
        },新Response.ErrorListener(){
            @覆盖
            公共无效onErrorResponse(VolleyError错误){
                pDialog.dismiss();
                INT的ErrorStatus = error.networkResponse!= NULL? error.networkResponse.status code
                        :0;
                Log.i(错误,error.toString()+
                        + ErrorStatus中);                AppController.getInstance()。getRequestQueue()
                。停止();                DRIVERQUERY DRIVERQUERY =新DRIVERQUERY(LoginConnection.this);
                driverQuery.open();
                Driver驱动,= driverQuery.getDriverExist(mlogin,util.md5(mPassword));                如果(driver.getId()!= 0){
                    GOTO(驱动器);
                    UtilClass.setSytemValue(driver_id,Integer.toString(driver.getId()),LoginConnection.this);                }否则如果(ErrorStatus中== 500){                    AlertDialog广告=新AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton(OK,NULL)
                    .setTitle(Problème)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(联合国problèmeEST survenue河畔乐serveur \\ NSI CELA persiste,veuillez查询联系人L'administrateur)
                    。创建();
                    ad.show();                }否则如果(ErrorStatus中== 400){                    AlertDialog广告=新AlertDialog.Builder(
                            LoginConnection.this)
                    .setPositiveButton(OK,NULL)
                    .setTitle(ERREUR)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(香格里拉syntaxe德拉requêteESTerronée。\\ NSI CELA persiste,veuillez查询联系人L'administrateur)
                    。创建();
                    ad.show();                }否则如果(ErrorStatus中== 404){                    AlertDialog广告=新AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton(OK,NULL)
                    .setTitle(ERREUR)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(标识不正确。\\ NSI CELA persiste,veuillez查询联系人L'administrateur)
                    。创建();
                    ad.show();                }否则如果(ErrorStatus中== 0){                    AlertDialog广告=新AlertDialog.Builder(LoginConnection.this)
                    .setPositiveButton(OK,NULL)
                    .setTitle(ERREUR)
                    .setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(乐临时工D'attente一个ETEdépassé。\\ NSI CELA persiste,veuillez查询联系人L'administrateur)
                    。创建();
                    ad.show();                }
                driverQuery.close();
            }
        }){
            @覆盖
            保护地图<字符串,字符串> getParams()方法{
                地图<字符串,字符串> PARAMS =新的HashMap<字符串,字符串>();                params.put(登陆,mlogin);
                params.put(密码,util.md5(mPassword));
                params.put(IMEI,getImei());
                params.put(registerId,UtilClass.getSytemValue(REGISTER_ID,LoginConnection.this));                Log.i(getParams,params.toString());
                返回checkParams(PARAMS);
            }
              私人地图<字符串,字符串> checkParams(地图<字符串,字符串>地图){
                    迭代器<钥匙进入LT;字符串,字符串>>它= map.entrySet()迭代器()。
                    而(it.hasNext()){
                        Map.Entry的<字符串,字符串>对=(Map.Entry的<字符串,字符串>)it.next();
                        如果(pairs.getValue()== NULL){
                            map.put(pairs.getKey(),);
                        }
                    }
                    返回地图;
                }        };        //添加请求,请求队列
        postReq.setRetryPolicy(新DefaultRetryPolicy(60 * 1000,1,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        。AppController.getInstance()addToAndStartRequestQueue(postReq);
        Log.i(TAG + - >缓存凌空,Integer.toString(rq.getSequenceNumber()));
}


解决方案

恩code使得StringRequest抽射之前,您的网址。或EN code的请求参数月底止。

i don't understand this error , although i search many many time on th net, but nothing to do , the error appear sometime. I did an app which use VOlley library , and all work well, 95% of my request works, but sometime i have the 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 appear. FOr example during y COnnection to the app , i send somes information like register_id for notification GCM , login, password and imei well, and sometime i have this error which appear 0_0

This is my Login request (but it's in all my 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()));


}

解决方案

Encode your URL before making StringRequest to volley. Or encode your end of request parameter only.

这篇关于Volley.NoConnectionError:java.io.EOFException 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆