Customer is NTT Corp and have JFB contract.
http://javaweb.sfbay.sun.com/cgi-bin/jfb/customer?d=ntt.eu
They reported their java application(HTTP client) only send Http Header and not send HTTP chunked body
when Web Server(they use Apache in their test case) is restarted under the condition that
keepalive is enabled.
This issue is not happened when http client sends data with content-length header.
This can be reproduced easily with sample program when Apache runs worker mode and keepalive is enabled.
Steps
--------------------------
1. Start Web Server(Apache) with worker mode and add following keepalive settings to httpd.conf
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
2. connect Web Server by using sample application(Main001.java).
3. restart Apache(apachectl restart).
--------------------------
a) This issue is only happened when http client sends data with chunked encoding.
(Please see attached Main001.java)
b) This issue is not happened when http client sends data with content-length header.
(attached Main002.java send data with content-length header)
Following is network capture and java thread dump when the issue is happened
10.188.179.134: Client
10.188.179.127: Web Server
38 40.021757 10.188.179.134 10.188.179.127 HTTP POST /test.txt HTTP/1.1 (application/x-www-form-urlencoded)
39 40.022734 10.188.179.127 10.188.179.134 TCP http > 60120 [ACK] Seq=1246 Ack=1281 Win=11264 Len=0
40 40.022764 10.188.179.127 10.188.179.134 HTTP HTTP/1.1 200 OK (text/plain)
---- httpd restart ---
41 40.023265 10.188.179.127 10.188.179.134 TCP http > 60120 [FIN, ACK] Seq=1557 Ack=1281 Win=11264 Len=0
42 40.023300 10.188.179.134 10.188.179.127 TCP 60120 > http [ACK] Seq=1281 Ack=1558 Win=65700 Len=0
43 50.025082 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
44 50.025302 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
45 50.025330 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
46 50.025354 10.188.179.134 10.188.179.127 HTTP POST /test.txt HTTP/1.1 (application/x-www-form-urlencoded)
47 50.025524 10.188.179.134 10.188.179.127 TCP 60120 > http [FIN, ACK] Seq=1537 Ack=1558 Win=65700 Len=0
48 50.026274 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
49 50.026293 10.188.179.134 10.188.179.127 TCP 60121 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2
50 50.026316 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
51 50.026333 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
52 50.026346 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
53 50.026358 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
54 50.027032 10.188.179.127 10.188.179.134 TCP http > 60121 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 WS=7
55 50.027056 10.188.179.134 10.188.179.127 TCP 60121 > http [ACK] Seq=1 Ack=1 Win=65700 Len=0
56 50.027367 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU] <---- only send http header ( hang )
57 50.028103 10.188.179.127 10.188.179.134 TCP http > 60121 [ACK] Seq=1 Ack=244 Win=6912 Len=0
After sending Http header, it seems java http client waits response from web server.
------------------------
"main" prio=6 tid=0x00179400 nid=0x1af0 runnable [0x001cf000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
- locked <0x24295e28> (a java.io.BufferedInputStream)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072)
- locked <0x24283f80> (a sun.net.www.protocol.http.HttpURLConnection)
at Main001.getUrl(Main001.java:53)
at Main001.doMain(Main001.java:22)
at Main001.main(Main001.java:9)
----------------
when Web Server(Apache) returns following response.
----------------------
HTTP/1.1 200 OK
Date: Fri, 29 Oct 2010 15:05:52 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 19 Oct 2010 05:50:09 GMT
ETag: "68928c-7-492f1dd92c640"
Accept-Ranges: bytes
Content-Length: 7
Keep-Alive: timeout=30, max=96
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
----------------------
As keepalive is enabled, java http client tries to use the same connection
and reconnect to web server if server reply Rest packet, but after reconnection,
java http client only sends http header and not sends chunked body.
http://javaweb.sfbay.sun.com/cgi-bin/jfb/customer?d=ntt.eu
They reported their java application(HTTP client) only send Http Header and not send HTTP chunked body
when Web Server(they use Apache in their test case) is restarted under the condition that
keepalive is enabled.
This issue is not happened when http client sends data with content-length header.
This can be reproduced easily with sample program when Apache runs worker mode and keepalive is enabled.
Steps
--------------------------
1. Start Web Server(Apache) with worker mode and add following keepalive settings to httpd.conf
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
2. connect Web Server by using sample application(Main001.java).
3. restart Apache(apachectl restart).
--------------------------
a) This issue is only happened when http client sends data with chunked encoding.
(Please see attached Main001.java)
b) This issue is not happened when http client sends data with content-length header.
(attached Main002.java send data with content-length header)
Following is network capture and java thread dump when the issue is happened
10.188.179.134: Client
10.188.179.127: Web Server
38 40.021757 10.188.179.134 10.188.179.127 HTTP POST /test.txt HTTP/1.1 (application/x-www-form-urlencoded)
39 40.022734 10.188.179.127 10.188.179.134 TCP http > 60120 [ACK] Seq=1246 Ack=1281 Win=11264 Len=0
40 40.022764 10.188.179.127 10.188.179.134 HTTP HTTP/1.1 200 OK (text/plain)
---- httpd restart ---
41 40.023265 10.188.179.127 10.188.179.134 TCP http > 60120 [FIN, ACK] Seq=1557 Ack=1281 Win=11264 Len=0
42 40.023300 10.188.179.134 10.188.179.127 TCP 60120 > http [ACK] Seq=1281 Ack=1558 Win=65700 Len=0
43 50.025082 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
44 50.025302 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
45 50.025330 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU]
46 50.025354 10.188.179.134 10.188.179.127 HTTP POST /test.txt HTTP/1.1 (application/x-www-form-urlencoded)
47 50.025524 10.188.179.134 10.188.179.127 TCP 60120 > http [FIN, ACK] Seq=1537 Ack=1558 Win=65700 Len=0
48 50.026274 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
49 50.026293 10.188.179.134 10.188.179.127 TCP 60121 > http [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=2
50 50.026316 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
51 50.026333 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
52 50.026346 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
53 50.026358 10.188.179.127 10.188.179.134 TCP http > 60120 [RST] Seq=1558 Win=0 Len=0
54 50.027032 10.188.179.127 10.188.179.134 TCP http > 60121 [SYN, ACK] Seq=0 Ack=1 Win=5840 Len=0 MSS=1460 WS=7
55 50.027056 10.188.179.134 10.188.179.127 TCP 60121 > http [ACK] Seq=1 Ack=1 Win=65700 Len=0
56 50.027367 10.188.179.134 10.188.179.127 TCP [TCP segment of a reassembled PDU] <---- only send http header ( hang )
57 50.028103 10.188.179.127 10.188.179.134 TCP http > 60121 [ACK] Seq=1 Ack=244 Win=6912 Len=0
After sending Http header, it seems java http client waits response from web server.
------------------------
"main" prio=6 tid=0x00179400 nid=0x1af0 runnable [0x001cf000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
- locked <0x24295e28> (a java.io.BufferedInputStream)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:652)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072)
- locked <0x24283f80> (a sun.net.www.protocol.http.HttpURLConnection)
at Main001.getUrl(Main001.java:53)
at Main001.doMain(Main001.java:22)
at Main001.main(Main001.java:9)
----------------
when Web Server(Apache) returns following response.
----------------------
HTTP/1.1 200 OK
Date: Fri, 29 Oct 2010 15:05:52 GMT
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 19 Oct 2010 05:50:09 GMT
ETag: "68928c-7-492f1dd92c640"
Accept-Ranges: bytes
Content-Length: 7
Keep-Alive: timeout=30, max=96
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
----------------------
As keepalive is enabled, java http client tries to use the same connection
and reconnect to web server if server reply Rest packet, but after reconnection,
java http client only sends http header and not sends chunked body.
- duplicates
-
JDK-7007889 HttpURLConnection does not send chunked Body to Web Server when reconnection is occurred
- Closed