Note: This article is from the blog "afei". If you want to repost this article, please contact the author! And indicate the source: http://blog.csdn.net/faye0412/article/details/7970155
These two days, I suddenly received the test team and told the company that the android client should be used on some mobile phones with the following exceptions, some of which were running well and were very strange:
1) httputils/getinputstream failed, E: received authentication challenge is null
PS: The application request uses httpconnection in Java instead of httpclient.
Later, tests on multiple mobile phones showed that such a problem exists and appeared on Android v4.04. Later, I checked the information and found that many people encountered similar problems, such:
1) http://d.hatena.ne.jp/Kazzz/20100706/p1
2) http://www.cnblogs.com/slider/archive/2012/07/16/2593816.html
In addition, we all use httpconnection in Java, which occurs when requesting authentication. Later, it was discovered that the server returned a 401 error (for example, when the user name and password are incorrect ). This is also a JDK bug. I found this bug in buglist. But I don't know how to solve it. So I replaced httpconnection with httpclient, and the result showed the following exception:
1) W/system. Err (18984): java.net. sockettimeoutexception: Read timed out
So I began to fall into another trap. After various tests, I found that it was setsotimeout (Params, 0) in httpclient. I set it to 4 s, later, I changed it to 20 s (this value occasionally causes problems), and then I set it to 0 to solve the problem.
It took me too much time to solve this problem... Record it here and give a reference to friends who have encountered the same problem.