hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Bentmann (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HTTPCLIENT-1188) HTTP client does not monitor connection for error status while sending request body
Date Fri, 27 Apr 2012 15:26:51 GMT
Benjamin Bentmann created HTTPCLIENT-1188:
---------------------------------------------

             Summary: HTTP client does not monitor connection for error status while sending
request body
                 Key: HTTPCLIENT-1188
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1188
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient
    Affects Versions: 4.1.3
            Reporter: Benjamin Bentmann


Quoting from http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.2:
bq. An HTTP/1.1 (or later) client sending a message-body SHOULD monitor the network connection
for an error status while it is transmitting the request. If the client sees an error status,
it SHOULD immediately cease transmitting the body. If the body is being sent using a "chunked"
encoding (section 3.6), a zero length chunk and empty trailer MAY be used to prematurely mark
the end of the message. If the body was preceded by a Content-Length header, the client MUST
close the connection. 

This is apparently not the case with the HttpClient. While uploading large files (tens of
MBs) whose transfer takes notable time (~ 30 sec) we observed the following exceptions (the
variation in detail msg are either due to Java version or OS):
{noformat}
java.net.SocketException: Broken pipe
  at java.net.SocketOutputStream.socketWrite0(Native Method)
  at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
  at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
  at com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:297)
  at com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:286)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:743)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:731)
  at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
  at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:153)
  at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:114)
  at org.apache.http.entity.FileEntity.writeTo(FileEntity.java:75)
  at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:96)
  at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
  at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:120)
  at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:264)
  at org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:224)
  at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:255)
  at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
  at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:647)
  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
  
java.net.SocketException: Connection reset by peer: socket write error
  at java.net.SocketOutputStream.socketWrite0(Native Method)
  at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
  at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
  at com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:297)
  at com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:286)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:748)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:736)
  at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:89)
  at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:153)
  at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:114)
  at org.apache.http.entity.FileEntity.writeTo(FileEntity.java:75)
  at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:96)
  at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
  at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:120)
  at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:264)
  at org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:224)
  at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:255)
  at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
  at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:647)
  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
{noformat}

The cause for those is apparently that the server sends an error response before fully consuming
the request body sent by the client. The server eventually closes the TCP connection (after
having notified the client via FIN and RST) but the client continues to upload and runs into
the closed server side.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message