Hi,

We are trying to solve a very simple problem for *HttpClient4* -- 
SocketException for HTTP GET. HttpClient4 gets the first "chunk" of data from 
server (Tomcat-6.0.18) and then the server unexpectedly closes the connection.

We tried the following HttpClient4 versions to fix this but it did not work!
- 4.1-beta1
- 4.1-alpha2
- 4.1-alpha1
- 4.0.3
- 4.0.2
- 4.0.1
The same piece of code works with HttpClient3.

Do you know if HTTP GET has any known bugs for HttpClient4? We could not find 
any on the internet.

The debug logs report the following:
Sending request: GET /layouts/xxxxx?websiteId=xxx&userId=xxxxx HTTP/1.1 
org.apache.http.wire - >> "GET /layouts/xxxxx?websiteId=xxx&userId=xxxxx 
HTTP/1.1[EOL]"
org.apache.http.wire - >> "Accept: application/json[EOL]"
org.apache.http.wire - >> "Host: xxx-xxxx.xxxxxxx.xxxxx[EOL]"
[note]
org.apache.http.wire - >> "Connection: Keep-Alive[EOL]"
org.apache.http.wire - >> "[EOL]"
org.apache.http.headers - >> GET /layouts/xxxxx?websiteId=xxx&userId=xxxxx 
HTTP/1.1 org.apache.http.headers - >> Accept: application/json 
org.apache.http.headers - >> Host: xxx-xxxx.xxxxxxx.xxxxx [note] 
org.apache.http.headers - >> Connection: Keep-Alive org.apache.http.wire - << 
"HTTP/1.1 200 OK[EOL]"
org.apache.http.wire - << "Date: Wed, 09 Feb 2011 09:53:15 GMT[EOL]"
org.apache.http.wire - << "Server: Apache-Coyote/1.1[EOL]"
org.apache.http.wire - << "Cache-Control: public, max-age=31536000000[EOL]"
org.apache.http.wire - << "Expires: Thu, 09 Feb 2012 09:53:15 GMT[EOL]"
org.apache.http.wire - << "Content-Type: application/json;charset=utf-8[EOL]"
org.apache.http.wire - << "Content-Language: en-GB[EOL]"
org.apache.http.wire - << "Content-Length: 7506[EOL]"
[note]
org.apache.http.wire - << "Connection: close[EOL]"
org.apache.http.wire - << "[EOL]"
org.apache.http.impl.conn.DefaultClientConnection - Receiving response: 
HTTP/1.1 200 OK org.apache.http.headers - << HTTP/1.1 200 OK 
org.apache.http.headers - << Date: Wed, 09 Feb 2011 09:53:15 GMT 
org.apache.http.headers - << Server: Apache-Coyote/1.1 org.apache.http.headers 
- << Cache-Control: public, max-age=31536000000 org.apache.http.headers - << 
Expires: Thu, 09 Feb 2012 09:53:15 GMT org.apache.http.headers - << 
Content-Type: application/json;charset=utf-8 org.apache.http.headers - << 
Content-Language: en-GB org.apache.http.headers - << Content-Length: 7506 
[note] org.apache.http.headers - << Connection: close 
uk.co.igindex.springrest.client.RequestProxyImpl - Http call return status 
code=200 [note] org.apache.http.impl.conn.DefaultClientConnection - Connection 
shut down org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager - 
Released connection is not reusable.
org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Releasing connection 
[HttpRoute[{}->http://xxx-xxx.xxx.xxxxx]][null]
StopsServer:2011-02-09 09:53:15,616 [main] DEBUG 
org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Notifying no-one, there are 
no waiting threads
Content-length: 7506
org.apache.http.wire - << "{"
org.apache.http.wire - << """
org.apache.http.wire - << "i"
...
[logs removed for partial response content]
---

We are reading the response in the standard way:
StringBuilder sb = new StringBuilder();
try {
   BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
   char[] buf = new char[4 * 1024]; // 4Kchar buffer
   int len;
   while ((len = br.read(buf, 0, buf.length)) != -1) {
      sb.append(buf, 0, len);
   }
   br.close();
   } finally {
      ...
   }
---

Thanks & Regards
Mahesh


The information contained in this email is strictly confidential and for the 
use of the addressee only, unless otherwise indicated. If you are not the 
intended recipient, please do not read, copy, use or disclose to others this 
message or any attachment. Please also notify the sender by replying to this 
email or by telephone (+44 (0)20 7896 0011) and then delete the email and any 
copies of it. Opinions, conclusions (etc.) that do not relate to the official 
business of this company shall be understood as neither given nor endorsed by 
it. IG Index Ltd is a company registered in England and Wales under number 
01190902. VAT registration number 761 2978 07. Registered Office: Cannon Bridge 
House, 25 Dowgate Hill, London EC4R 2YA. Authorised and regulated by the 
Financial Services Authority. FSA Register number 114059.

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to