android - Okhttp infinite loop on change connection status -


i have simple code making request okhttp lib:

    request request = new request.builder()             .url(url)             .build();     log.d("tag", "start");     response response = httpclient.newcall(request).execute();     log.d("tag", "stop"); 

everything works well, unless try change connection, while execute request. ex, if try connect without wifi (with slow internet connection), , turn on wifi while it's in progress execute infinitely. if stay slow mobile internet or stay wifi (without changing connection type) works fine. same story when turn off connections, start execution , turn on connection. tried use timeout, doesn't help.

edit. there no other valuable code:

private class downloadxmltask extends asynctask<string, void, void> {     private asynccallback<reader> callback;      private downloadxmltask(asynccallback<reader> callback) {         this.callback = callback;     }      @override     protected void doinbackground(string... urls) {         try {             reader result = dogetrequest(urls[0]);             callback.success(result);         } catch (ioexception e) {             log.debug(context.getresources().getstring(r.string.error_http_request), e);             callback.failure(context.getresources().getstring(r.string.error_http_request), e);         }         return null;     }  }  private reader dogetrequest(string url) throws ioexception {         request request = new request.builder()                 .url(url)                 .build();         log.d("mytag", "start");         response response = httpclient.newcall(request).execute();         log.d("mytag", "stop");         return response.body().charstream();     } 

okhttp version:

compile 'com.squareup.okhttp:okhttp:2.3.0' 


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -