Android 3G上的OKHTTP意外状态行
我正在开发一个应用程序,在使用okhttp发出POST请求时遇到问题 堆栈跟踪(okhttp): 这只发生在3G上,在特定的平板电脑上,在Wi-Fi上,它可以在同一台设备上正常工作。在其他设备上,它可以在3G和Wi-Fi上正常工作 对于登录请求,我使用okhttp发出请求。对于其他请求,我使用了改装。当我切换到使用Rertofit进行登录请求时,发生了一件奇怪的事情。有时有效,有时崩溃 使用改装时的堆栈跟踪:Android 3G上的OKHTTP意外状态行,android,retrofit,okhttp,Android,Retrofit,Okhttp,我正在开发一个应用程序,在使用okhttp发出POST请求时遇到问题 堆栈跟踪(okhttp): 这只发生在3G上,在特定的平板电脑上,在Wi-Fi上,它可以在同一台设备上正常工作。在其他设备上,它可以在3G和Wi-Fi上正常工作 对于登录请求,我使用okhttp发出请求。对于其他请求,我使用了改装。当我切换到使用Rertofit进行登录请求时,发生了一件奇怪的事情。有时有效,有时崩溃 使用改装时的堆栈跟踪: 12-29 09:42:51.337: D/Retrofit(2766): ----
12-29 09:42:51.337: D/Retrofit(2766): ---- ERROR http://MYSERVER.com:2258/api/loginTaxi
12-29 09:42:51.352: D/Retrofit(2766): java.net.ProtocolException: Unexpected status line: HTTP/1.1
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.StatusLine.parse(StatusLine.java:59)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:187)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:78)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:665)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:429)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:374)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:469)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
12-29 09:42:51.352: D/Retrofit(2766): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-29 09:42:51.352: D/Retrofit(2766): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.Platform$Android$2$1.run(Platform.java:142)
12-29 09:42:51.352: D/Retrofit(2766): at java.lang.Thread.run(Thread.java:856)
12-29 09:42:51.352: D/Retrofit(2766): ---- END ERROR
我正在使用okhttp-2.1.0、okhttp-urlconnection-2.1.0和okio-1.1.0
以及在删除okhttp时(使用默认http客户端的改型)
12-29 10:24:19.837:D/改装(4727):java.lang.IllegalArgumentException:无效状态代码:-1
12-29 10:24:19.837:D/Reformation(4727):在reformation.client.Response.(Response.java:42)
12-29 10:24:19.837:D/reformation(4727):在reformation.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:94)
12-29 10:24:19.837:D/reformation(4727):在reformation.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
12-29 10:24:19.837:D/改装(4727):在改装.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
12-29 10:24:19.837:D/Reformation(4727):在reformation.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
12-29 10:24:19.837:D/改装(4727):在改装时。RestAdapter$RestHandler$2。获取响应(RestAdapter.java:278)
12-29 10:24:19.837:D/改装(4727):在改装处.CallbackRunnable.run(CallbackRunnable.java:42)
12-29 10:24:19.837:D/改装(4727):位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-29 10:24:19.837:D/改装(4727):位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-29 10:24:19.837:D/Reformation(4727):在Reformation.Platform$Android$2$1.run(Platform.java:142)
12-29 10:24:19.837:D/改装(4727):在java.lang.Thread.run(Thread.java:856)处
12-29 10:24:19.837:D/改装(4727):----结束错误
知道发生了什么吗?默认的APN包含一个代理,它干扰了我们的请求/响应 从APN中删除代理可以解决这些问题
12-29 09:42:51.337: D/Retrofit(2766): ---- ERROR http://MYSERVER.com:2258/api/loginTaxi
12-29 09:42:51.352: D/Retrofit(2766): java.net.ProtocolException: Unexpected status line: HTTP/1.1
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.StatusLine.parse(StatusLine.java:59)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:187)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:78)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:665)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:429)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:374)
12-29 09:42:51.352: D/Retrofit(2766): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:469)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
12-29 09:42:51.352: D/Retrofit(2766): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-29 09:42:51.352: D/Retrofit(2766): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-29 09:42:51.352: D/Retrofit(2766): at retrofit.Platform$Android$2$1.run(Platform.java:142)
12-29 09:42:51.352: D/Retrofit(2766): at java.lang.Thread.run(Thread.java:856)
12-29 09:42:51.352: D/Retrofit(2766): ---- END ERROR
12-29 10:24:19.837: D/Retrofit(4727): java.lang.IllegalArgumentException: Invalid status code: -1
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.client.Response.<init>(Response.java:42)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:94)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
12-29 10:24:19.837: D/Retrofit(4727): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-29 10:24:19.837: D/Retrofit(4727): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-29 10:24:19.837: D/Retrofit(4727): at retrofit.Platform$Android$2$1.run(Platform.java:142)
12-29 10:24:19.837: D/Retrofit(4727): at java.lang.Thread.run(Thread.java:856)
12-29 10:24:19.837: D/Retrofit(4727): ---- END ERROR