[Android Exception 1A] -com.android.volley.NoConnectionError: java.io.InterruptedIOException

12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err: com.android.volley.NoConnectionError: java.io.InterruptedIOException
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:125)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err: Caused by: java.io.InterruptedIOException
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okio.Deadline.throwIfReached(Deadline.java:56)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okio.Okio$1.write(Okio.java:67)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okio.RealBufferedSink.flush(RealBufferedSink.java:154)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpConnection.flush(HttpConnection.java:130)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpTransport.flushRequest(HttpTransport.java:73)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:626)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:109)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
12-24 14:21:47.470 24220-24220/com.tongyan.tutelage W/System.err:     ... 1 more

这个错误是你在不经意间导致的,或者是没有很好的去熟悉volley包的api导致的。

public void onRequest(String url){
        if(isIntnetConn){
            StringRequest request = new StringRequest(url, new Response.Listener<String>() {
                @Override
                public void onResponse(String s) {
                    mListener.onSuccess(s);
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    String errorMsg = "";
                    if(volleyError instanceof TimeoutError) {
                        mListener.onError();
                    } else if(volleyError instanceof ServerError) {
                        mListener.onError();
                    } else {
                        mListener.onError();
                        errorMsg = mContext.getResources().getString(R.string.request_error);
                    }
                }
            });
            request.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 0, 1.0f));//设置超时时间
            mQueue.add(request);
            //mQueue.start();
        }else{
            Toast.makeText(mContext, "当前的网络连接不可用", Toast.LENGTH_SHORT).show();
            mListener.onIntnetDisConn();
        }
    }

只是因为加了下面这句,bug如期而至。

//mQueue.start();

其实,在RequestQueue实例化的时候,就已经有start了。

private RequestQueue mQueue;
private Context mContext;

public HttpServiceUtils(HttpResquestListener listener,Context context){
       mListener = listener;
       mContext = context;
       mQueue  = Volley.newRequestQueue(context);
}
public class Volley {
    private static final String DEFAULT_CACHE_DIR = "volley";

    public Volley() {
    }

    public static RequestQueue newRequestQueue(Context context, HttpStack stack) {
        File cacheDir = new File(context.getCacheDir(), "volley");
        String userAgent = "volley/0";

        try {
            String network = context.getPackageName();
            PackageInfo queue = context.getPackageManager().getPackageInfo(network, 0);
            userAgent = network + "/" + queue.versionCode;
        } catch (NameNotFoundException var6) {
            ;
        }

        if(stack == null) {
            if(VERSION.SDK_INT >= 9) {
                stack = new HurlStack();
            } else {
                stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent));
            }
        }

        BasicNetwork network1 = new BasicNetwork((HttpStack)stack);
        RequestQueue queue1 = new RequestQueue(new DiskBasedCache(cacheDir), network1);
        queue1.start();
        return queue1;
    }

    public static RequestQueue newRequestQueue(Context context) {
        return newRequestQueue(context, (HttpStack)null);
    }
}

queue1.start(); 已经在实例化RequestQueue的时候,就被调用了。

https://stackoverflow.com/questions/31158858/random-com-android-volley-noconnection-error-java-io-interruptedioexception-st/31181611#31181611

时间: 2024-10-13 00:27:57

[Android Exception 1A] -com.android.volley.NoConnectionError: java.io.InterruptedIOException的相关文章

hadoop错误Ignoring exception during close for [email&#160;protected] java.io.IOException Spill failed

1.错误    Ignoring exception during close for [email protected] java.io.IOException: Spill failed2.原因     本地磁盘空间不足非hdfs (我是在myeclipse中调试程序,本地tmp目录占满)3.解决     清理.增加空间 如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的[推荐]. 如果,您希望更容易地发现我的新博客,不妨点击一下左下角的[关注我]. 如果,您对我的博客所讲述的内容有

严重: Exception loading sessions from persistent storage java.io.EOFException

启动项目时报以下异常 严重: Exception loading sessions from persistent storage java.io.EOFException 遇到上述异常,删除Tomcat里面的work\Catalina\localhost下的项目文件内容即可解决. 原因是由于项目测试中class文件或者其它文件更新过频繁. 之前经常碰到页面修改后,重新发布的项目页面还是原样,不管删掉tomcat/webapps/发布的项目还是重新部署,都无法显示修改后的效果, 但是其他页面修改

tomcat错误之:Exception loading sessions from persistent storage java.io.EOFException

解决办法: 删除 例如:E:\Soft\apache-tomcat-7.0.42\work\Catalina\localhost  即删除tomcat下面的localhost下的所有文件,再重新部署项目,即可.

【转】Tomcat出现SEVERE: IOException while loading persisted sessions: java.io.EOFException java.io.EOFException问题的解决方案

[java] view plaincopy 错误代码如下: 严重: IOException while loading persisted sessions: java.io.EOFException java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325) at java.io.ObjectInputStream$BlockDataInputS

tomcat启动报java.io.NotSerializableException或者WriteAbortedException错误解决方法

NotSerializableException或者WriteAbortedException 运行tomcat下面的 ssh项目,启动,打开某页面(让session起作用),停止:再启动,有可能会报类似如下的错误: org.apache.catalina.session.StandardManager doLoad 严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing a

tomcat启动时报:IOException while loading persisted sessions: java.io.EOFException的解决方案

严重: IOException while loading persisted sessions: java.io.EOFExceptionjava.io.EOFException    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2284)    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInp

hive执行query语句时提示错误:org.apache.hadoop.ipc.RemoteException: java.io.IOException: java.io.IOException:

hive> select product_id, track_time from trackinfo limit 5; Total MapReduce jobs = 1 Launching Job 1 out of 1 Number of reduce tasks is set to 0 since there's no reduce operator org.apache.hadoop.ipc.RemoteException: java.io.IOException: java.io.IOEx

tomcat启动报:严重: IOException while loading persisted sessions: java.io.EOFException

严重: IOException while loading persisted sessions: java.io.EOFException ................................... . .. org.apache.catalina.session.StandardManager start 严重: Exception loading sessions from persistent storage java.io.EOFException at java.io.O

IOException while loading persisted sessions: java.io.EOFException

严重: IOException while loading persisted sessions: java.io.EOFExceptionjava.io.EOFException    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2303)    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInp