commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Kriger <andy.kri...@gmail.com>
Subject [HTTPCLIENT] Broken pipe?
Date Mon, 26 Sep 2005 16:38:28 GMT
Hello,

I am using HttpClient 3.0-rc3 to submit a multipart/form-data POST
containing several fields with values and a file. The request is
failing because of a SocketException: Broken pipe. I have turned on
all context and wire logging. I see the content in the log but it gets
cutoff by the exception midway. The problem happens while the file
part is being written - it is about 2Mb of content. I'm wondering if
anyone can point me in the write direction for debugging this problem.

Thank you,
andy

Here is my code....
PostMethod post = new PostMethod(/*URL*/);
Part[] parts = {
		new FilePart(FIELD_FILE, new ByteArrayPartSource("submission.xfdl",
xfdl.getBytes())),
		new StringPart(FIELD_LIVETEST, VALUE_TEST),
		new StringPart(FIELD_BULKSING, VALUE_SINGLE),
		new StringPart(FIELD_MSG, ""),
		new StringPart(FIELD_SESSION, sessionId)
};
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
HttpMethodParams mParams = new HttpMethodParams();
mParams.setParameter(HttpMethodParams.RETRY_HANDLER, new
HttpMethodRetryHandler() {
	public boolean retryMethod(HttpMethod httpMethod, IOException
ioException, int i)
		{
			return false;
		}
});
post.setParams(mParams);

HttpClientParams cParams = new HttpClientParams();
cParams.setSoTimeout(0); // TO ENSURE ENOUGH TIME
HttpClient client = new HttpClient(cParams);
int response = client.executeMethod(post);

Start of content logging...
<everything before FilePart not included>
    [junit] 2516 DEBUG
org.apache.commons.httpclient.methods.multipart.FilePart  - enter
sendDispositionHeader(OutputStream out)
    [junit] 2516 DEBUG
org.apache.commons.httpclient.methods.multipart.Part  - enter
sendDispositionHeader(OutputStream out)
    [junit] 2516 DEBUG httpclient.wire.content  - >>
"Content-Disposition: form-data; name="
    [junit] 2516 DEBUG httpclient.wire.content  - >> """
    [junit] 2516 DEBUG httpclient.wire.content  - >> "file"
    [junit] 2516 DEBUG httpclient.wire.content  - >> """
    [junit] 2516 DEBUG httpclient.wire.content  - >> "; filename="
    [junit] 2516 DEBUG httpclient.wire.content  - >> """
    [junit] 2516 DEBUG httpclient.wire.content  - >> "xydk_44151.tmp"
    [junit] 2516 DEBUG httpclient.wire.content  - >> """
    [junit] 2516 DEBUG
org.apache.commons.httpclient.methods.multipart.Part  - enter
sendContentTypeHeader(OutputStream out)
    [junit] 2517 DEBUG httpclient.wire.content  - >> "[\r][\n]"
    [junit] 2517 DEBUG httpclient.wire.content  - >> "Content-Type: "
    [junit] 2517 DEBUG httpclient.wire.content  - >> "application/octet-stream"
    [junit] 2517 DEBUG httpclient.wire.content  - >> "; charset="
    [junit] 2517 DEBUG httpclient.wire.content  - >> "ISO-8859-1"
    [junit] 2517 DEBUG
org.apache.commons.httpclient.methods.multipart.Part  - enter
sendTransferEncodingHeader(OutputStream out)
    [junit] 2517 DEBUG httpclient.wire.content  - >> "[\r][\n]"
    [junit] 2517 DEBUG httpclient.wire.content  - >>
"Content-Transfer-Encoding: "
    [junit] 2517 DEBUG httpclient.wire.content  - >> "binary"
    [junit] 2517 DEBUG
org.apache.commons.httpclient.methods.multipart.Part  - enter
sendEndOfHeader(OutputStream out)
    [junit] 2517 DEBUG httpclient.wire.content  - >> "[\r][\n]"
    [junit] 2517 DEBUG httpclient.wire.content  - >> "[\r][\n]"
    [junit] 2517 DEBUG
org.apache.commons.httpclient.methods.multipart.FilePart  - enter
sendData(OutputStream out)
    [junit] 2517 DEBUG
org.apache.commons.httpclient.methods.multipart.FilePart  - enter
lengthOfData()
    [junit] 5948 DEBUG httpclient.wire.content  - >> "<?xml
version="1.0" encoding="UTF-8"?>[\n]"

Midway through the output of content in the wire logging it blows up...

[junit] 36110 DEBUG org.apache.commons.httpclient.HttpMethodDirector 
- Closing the connection.
    [junit] 36124 DEBUG org.apache.commons.httpclient.HttpConnection 
- enter HttpConnection.close()
    [junit] 36124 DEBUG org.apache.commons.httpclient.HttpConnection 
- enter HttpConnection.closeSockedAndStreams()
    [junit] 36124 DEBUG
org.apache.commons.httpclient.HttpMethodDirector  - Method retry
handler returned false. Automatic recovery
will not be attempted
    [junit] 36124 DEBUG org.apache.commons.httpclient.HttpConnection 
- enter HttpConnection.releaseConnection()
    [junit] 36124 DEBUG org.apache.commons.httpclient.HttpConnection 
- Releasing connection back to connection manager.
    [junit] 36124 ERROR com.capitalprinting.webservices.util.EdgarSite
 - java.net.SocketException: Broken pipe
    [junit] 36125 DEBUG org.apache.commons.httpclient.HttpConnection 
- enter HttpConnection.releaseConnection()
    [junit] 36125 DEBUG org.apache.commons.httpclient.HttpConnection 
- Releasing connection back to connection manager.
    [junit] ------------- ---------------- ---------------
    [junit] Testcase:
testTestSubmission(com.capitalprinting.webservices.util.EdgarSiteTest):
  Caused an ERROR
    [junit] Broken pipe
    [junit] java.net.SocketException: Broken pipe
    [junit]     at java.net.SocketOutputStream.socketWrite0(Native Method)
    [junit]     at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    [junit]     at
java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    [junit]     at
com.sun.net.ssl.internal.ssl.OutputRecord.writeBuffer(OutputRecord.java:283)
    [junit]     at
com.sun.net.ssl.internal.ssl.OutputRecord.write(OutputRecord.java:272)
    [junit]     at
com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:663)
    [junit]     at
com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
    [junit]     at
java.io.BufferedOutputStream.write(BufferedOutputStream.java:105)
    [junit]     at
org.apache.commons.httpclient.WireLogOutputStream.write(WireLogOutputStream.java:67)
    [junit]     at
org.apache.commons.httpclient.methods.multipart.FilePart.sendData(FilePart.java:225)
    [junit]     at
org.apache.commons.httpclient.methods.multipart.Part.send(Part.java:311)
    [junit]     at
org.apache.commons.httpclient.methods.multipart.Part.sendParts(Part.java:381)
    [junit]     at
org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity.writeRequest(MultipartRequestEntity.java:1
53)
    [junit]     at
org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
    [junit]     at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
    [junit]     at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
    [junit]     at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:393)
    [junit]     at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:168)
    [junit]     at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    [junit]     at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message