Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 72670 invoked from network); 14 Aug 2003 08:47:12 -0000 Received: from unknown (HELO ?62.161.101.69?) (62.161.101.69) by daedalus.apache.org with SMTP; 14 Aug 2003 08:47:12 -0000 Received: from mail-serveur.vigis.com by [62.161.101.69] via smtpd (for daedalus.apache.org [208.185.179.12]) with SMTP; Thu, 14 Aug 2003 10:48:47 +0200 content-class: urn:content-classes:message Subject: (HttpClient) Posting large files using MultipartPostMethod MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Thu, 14 Aug 2003 10:47:17 +0200 Message-ID: X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: (HttpClient) Posting large files using MultipartPostMethod Thread-Index: AcNiQKpa+zDKi1z1RAeousaFPjleng== From: "Dennis SELLINGER" To: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi, I have been trying to implement a simple client to upload a file to a = servlet. The code I use is pretty basic (summarized below). I find = that it works for files that are sufficiently small (<128 K) but gives = the following error for larger files: 14 ao=FBt 2003 10:19:55 com.vigis.designfilereplication.Replicator = postReplicationRequest GRAVE: I/O error while executing replication post request... root cause = Software caused connection abort: socket write error java.net.SocketException: Software caused connection abort: socket write = error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(Unknown Source) at java.net.SocketOutputStream.write(Unknown Source) at = org.apache.commons.httpclient.HttpConnection$WrappedOutputStream.write(Ht= tpConnection.java:1344) at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.write(Unknown Source) at = org.apache.commons.httpclient.methods.multipart.FilePart.sendData(FilePar= t.java:300) at = org.apache.commons.httpclient.methods.multipart.Part.send(Part.java:294) at = org.apache.commons.httpclient.methods.multipart.Part.sendParts(Part.java:= 344) at = org.apache.commons.httpclient.methods.MultipartPostMethod.writeRequestBod= y(MultipartPostMethod.java:262) at = org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.= java:2224) at = org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBas= e.java:2534) at = org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:= 1047) at = org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:63= 8) at = org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:50= 0) at = com.vigis.designfilereplication.Replicator.postReplicationRequest(Replica= tor.java:424) at com.vigis.designfilereplication.Replicator.main(Replicator.java:170) My client is running on Java 1.4.2 under windows xp sp1. In the case = where the post fails, I don't think that it arrives at my server (i.e. = my servlet does not start running the getPost() method). My server is a = servlet running under tomcat 4.1.x using the = com.oreilly.servlet.MultipartRequest API to handle the upload. This = servlet has be used extensively with multipart posts originalating from = Internet Explorer, so there should be no problems with it. Here is a cleaned up version of the code I am executing: MultipartPostMethod post =3D new = MultipartPostMethod("http://alsace/vwjserv/accept/dea93"); HttpClient client =3D new HttpClient(); client.setConnectionTimeout(5000); UsernamePasswordCredentials credentials =3D new = UsernamePasswordCredentials("-----","-----"); client.getState().setCredentials("realm","host",credentials); post.setDoAuthentication(true); try { File archive1 =3D new File("c:/test.txt"); post.addParameter("VIGIS_ULD00",archive1); } catch (FileNotFoundException e1) { ... } post.addParameter("instant",Long.toHexString(this.instant.getTime())); int statusCode =3D -1; int retryCount =3D 0; boolean retry =3D true; while (retry) { try { statusCode =3D client.executeMethod(post); retry =3D false; } catch (HttpRecoverableException hrx) { ... } catch (HttpException e) { ... } catch (IOException e) { =09 ... } } I think the code is pretty clean, but I am obviously missing a parmeter = or something. Any help would be appreciated. Thanks in advance, Dennis. Dennis Sellinger Geotech France.