Dims,
I am sending mult-part request using HttpClient. When I try reading
from the IncomingAttachmentStream, I get read-time-out error on the
last attachment. It seems the location where read-time-out occurs
depends on the content of stream input. Repeated attempts of a same
request always timesout at the same location. Adding another
attachment to the same request runs into readtime out on the last
attachment. This seems like the read buffer is blocked. When I
intercept the incoming request using TCPMon, the entire request is
there. Hence, I don't think it's a flush problem from the sender
side.
Any idea? Am I missing something?
Here is the code snippet:
private void getAttachments(MessageContext msgCtx) throws IOException {
Attachments attchts = msgCtx.getAttachmentMap();
IncomingAttachmentStreams instreams =
attchts.getIncomingAttachmentStreams();
int attchtIndex = 1;
while (instreams.isReadyToGetNextStream()) {
IncomingAttachmentInputStream instream = null;
try {
instream = instreams.getNextStream();
if (instream == null)
break;
System.out.println("\n\n-------------------- content= "
+
instream.getContentId() + " ---------------------");
Map headers = instream.getHeaders();
for (Iterator iter = headers.keySet().iterator();
iter.hasNext(); ) {
String header = (String) iter.next();
System.out.println("header: " + header + " = "
+ headers.get(header));
}
System.out.println("-------------------------------------------------------\n\n");
readContent(attchtIndex++, instream);
}
finally {
if (instream != null) {
instream.close();
}
}
}
}
private void readContent(int attachmentIndex,
IncomingAttachmentInputStream instream) throws IOException {
byte buffer[] = new byte[1024];
File file = new File(baseOutputDir + File.separator +
attachmentIndex + ".out");
FileOutputStream fout = null;
try {
int len;
fout = new FileOutputStream(file);
while ((len = instream.read(buffer)) > 0 ) {
fout.write(buffer, 0, len);
}
fout.flush();
}
finally {
if (fout != null) {
fout.close();
}
}
}
Exception statck:
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at
org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:747)
at
org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:777)
at
org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:115)
at
org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:712)
at org.apache.coyote.Request.doRead(Request.java:429)
at
org.apache.coyote.tomcat5.InputBuffer.realReadBytes(InputBuffer.java:290)
at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:374)
at org.apache.coyote.tomcat5.InputBuffer.read(InputBuffer.java:305)
at
org.apache.coyote.tomcat5.CoyoteInputStream.read(CoyoteInputStream.java:179)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:313)
at java.io.FilterInputStream.read(FilterInputStream.java:111)
at java.io.PushbackInputStream.read(PushbackInputStream.java:161)
at
org.apache.axiom.attachments.BoundaryDelimitedStream.readFromStream(BoundaryDelimitedStream.java:215)
at
org.apache.axiom.attachments.BoundaryDelimitedStream.read(BoundaryDelimitedStream.java:302)
at
org.apache.axiom.attachments.BoundaryDelimitedStream.read(BoundaryDelimitedStream.java:359)
at
org.apache.axiom.attachments.IncomingAttachmentInputStream.read(IncomingAttachmentInputStream.java:127)
...
Thanks again,
Jennifer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]