Urgent: Uploading file, cannot receive InputStream SocketTimeOutException

Hey everyone,
I am going crazy with this. We have a server that supprots HTTP1.1 and Transfer-Encoding: chunked.
We have written a mobile app that uploads a file to the server using URLConnection. Due to low memory on the phone we do not want to buffer all data and send it in once erquest. Instead we want it to be streamed through.
We found out that Transfer-encoding: chunked does this. It actually works, we can see the network data being streamed while its being read.
The problem starts after the file has been sent. We are unable to retrieve the InputStream. We get a SocketTimeoutException.after requesting the InputStream.
InputStream is = httpConn.getInputStream(); //This line causes the timeout.
It seems as if the server DOES NOT KNOW we are done sending the file? We read the documentation for chunked send and according to wikipedia we have to add a zero-size chunk at the end.
We have tried adding this but still we are getting this exception. Not sure if we tried it correctly though.
Can anyone please help? This is very urgent.
Thank you,
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(buffer, true, "ISO-8859-1");
pout.print("--" +boundary);
for (String[] arg : pars) {
pout.print(LINE_BREAK);
pout.print("Content-Disposition: form-data; name=\""+ arg[0] +"\"");
pout.print(LINE_BREAK+ LINE_BREAK);
pout.print(arg[1]);
pout.print(LINE_BREAK);
pout.print("--" +boundary);
pout.print(LINE_BREAK);
pout.print("Content-Disposition: form-data; filename="+ URLEncoder.encode(fileName));
pout.print(LINE_BREAK);
pout.print("Content-Type: " +mimeType);
pout.print(LINE_BREAK+ LINE_BREAK);
pout.close();
con.connect();
OutputStream out = con.getOutputStream();
out.write(buffer.toByteArray());
out.flush();
byte[] buf = new byte[2048];
int read;
long processed = 0;
while ((read = data.read(buf)) > 0) {
if (isCancelled()) {
out.close();
return;
/ *DATA GETS SEND HERE ONLY IF WE SET Transfer-Encoding: chunked OR USE setChunkedStreamingMode(xxxx);* /+ --+
out.write(buf, 0, read);+ --+
processed+ --+= read;
publishProgress((int) (100 * processed / fileLength));
out.write(ending);
out.close();
}aBs
Edited by: aBsOlUtJava on Jul 2, 2009 3:36 PM
Edited by: aBsOlUtJava on Jul 2, 2009 3:40 PM
Edited by: aBsOlUtJava on Jul 2, 2009 3:40 PM

Hey,
Sorry I wrapped the code in tags. Yes I have tried using the Content-Length header.
If I avoid getting the InputStream the upload works, but I want to get the InputStream to read the servers response as some files can be rejected.
Please see: http://en.wikipedia.org/wiki/Chunked_transfer_encoding, it says something a zero-chunk at the end. Is the reason perhaps that the server does not know my upload and request is done?
I apologize for the urgent mark, I have been trying for 48 hours on this and I am going crazy =(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Get error message "this "**" file cannot be attached until the files already attached are finished uploading" even when attaching 1 file

    I attached multiples .pdf files to an email. Tried to attach the next file before the previous 1 finished attaching. Got error message "this "**" file cannot be attached until the files already attached are finished uploading". Was never able to attach that 1 file to the email that I received the error message for; was able to attach subsequent files to that same email & send it. Now, I often get the same error message, even if I only attach 1 file & esp. when attaching .ai or .jpeg files. What can I do to fix this problem?

    It looks like nobody has an answer for this despite of the 80 something views!
    And here i thought Adobe admin would be monitoring the forum, but surprisingly, they don't even have the answer for this!!!

  • How to get InputStream of uploaded file from request?

    The situation:
    Client is uploading xml file to server.
    <form METHOD=POST ENCTYPE = "multipart/form-data" action="SendFile" accept="text/xml">
              <input type="file" name="SentFile" />
              <input type="submit" value="go"/>
    </form>Then I need to parse data from file.
    I want to use method javax.xml.parsers.DocumentBuilder.parse(InputStream is)
    But, how to get InputStream of uploaded file from request?

    You cannot get the InputStream of the uploaded file directly. The InputStream you can obtain from request.getInputStream() contains a lot of other data as well as the uploaded file. You will have to parse the data in the InputStream to find the data that belongs to the file.
    A short cut is to use the HTTP Multipart File Upload available from www.jenkov.com. It simplifies file upload and makes it easy to obtain an InputStream for only the uploaded file. It also handles upload of multiple files. It is free, open source, Apache license, so if it doesn't fit your needs, you can always read the code and see how it works. Then write your own upload servlet.

  • I can't open my Itunes keep receiving error message- The iTunes Library.itl file cannot be found or created. The default location for this file is in the "i Tunes" folder in the "Music" folder

    I can't open my Itunes keep receiving error message- The iTunes Library.itl file  cannot be found or created. The default location for this file is in the "i Tunes" folder in the "Music" folder. I have even tried removing and reinstalling iTunes and it still does work because I continue to receive this error message. Please Help!

    Anyone can help to advice how to solve this issue ?

  • Reversal of stock upload file:- Urgent

    Gurus,
        By mistake at intial stock upload file is  upladed twice, how could i reverse  the same. I uploaded  through   T -code MB1C/ Mvt type 561; and showing at 998 storage type( interemediate bins). How could I will reverse the excess stock from the same.
    Please let me know the process . its is urgent. by what logic shoulsd I make  BDCetc.
    Regds,
    Sanjay rahangdale
    [email protected]

    Hi,
    re run the file again but this time with a 562 movement type, this should reverse the error exactly how you want it.
    Steve b

  • I upgraded iTunes to 11.  I now receive an error message which reads - 'The iTunes Library file cannot be saved. An unknown error occurred (-50).  How do I correct this error?

    I upgraded iTunes to 11.  I now receive an error message which reads - 'The iTunes Library file cannot be saved. An unknown error occurred (-50).  How do I correct this error?
    Thanks
    TDB

    I know this doesn't help you Bud, but I've had this issue for at least the last couple of versions.  If I can ask, what is you enviornment like?  Local PC only, libray saved on another PC/Server? 
    In my case my library is on Windows 2003 server with the share mapped to drive M:  This has worked for many years through both XP and Windows 7 until and update a while ago. 
    Thanks,
    Rob

  • I worked on a Photshop file yesterday, but today, I received a notification that the file cannot open because it is incompatible. Please help!

    The notification simply states that the file is incompatible with my current version of Photoshop, which is crazy because it was working fine until now and I need to work on this and multiple other files.

    Thank you!
          From: gener7 <[email protected]>
    To: Natalie Fosdick <[email protected]>
    Sent: Tuesday, November 25, 2014 8:35 PM
    Subject:  I worked on a Photshop file yesterday, but today, I received a notification that the file cannot open because it is incompatible. Please help!
    I worked on a Photshop file yesterday, but today, I received a notification that the file cannot open because it is incompatible. Please help!
    created by gener7 in Photoshop General Discussion - View the full discussionIf you have Windows, you can get a backup "shadow copy" of your files if it has been turned on. Shadow explorer will help you find and restore the earlier file. ShadowExplorer.com - About Also go into Photoshop Preferences > File Handling and set Maximize Compatibility for PSD and PSB files to "Always". Gene If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/6963078#6963078 and clicking ‘Correct’ below the answer Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/6963078#6963078 To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"  Start a new discussion in Photoshop General Discussion by email or at Adobe Community For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • My phone cannot receive file from pc using bluetoo...

    I got problem with my phone that cannot receiving file from my pc via bluetooth,
    but there's no any trouble if i send or receiveing file from other mobile phone,
    someone please explain and give me the solution

    I'm using nokia 5530 XM

  • I am receiving this error message..."The iTunes file cannot be saved. An unknown error occured (-50).

    I am receiving this error message..."The iTunes file cannot be saved. An unknown error occured (-50).
    How can I fix this problem?

    Hi cass1810,
    If you are getting a -50 error when using iTunes, you may find the following article helpful:
    iTunes Store: "Error (-50)" when downloading purchased content
    http://support.apple.com/kb/TS1583
    Regards,
    - Brenden

  • Upload File Validation Urgent pls..........................

    hi ,
    i want to validate FileAttachment If i give some junk data in IE7 It is not executing that page but it's working fine in IE6 And if i give more than 2MB,it is not enter inside the if loop ( if(attachmentFileName != null {...... }) at all .this is my code
    if(attachmentFileName != null){
    try{
    InputStream inputStream = new FileInputStream(attachmentFileName);
    if(attachmentFileName.length() > ApplicationDefs.TWO_MB){ addActionError("Sorry your file is size is greater than 2 MB");
    return;
    if(inputStream.available() == 0){
    addActionError("Invalid file format");
    return;
    if(!isValidFileFormat(attachmentFileName)){
    addActionError("Invalid file format");
    return;
    }catch(FileNotFoundException fne){
    addActionError("Uploaded file not found");
    return;
    }catch(IOException io){
    addActionError("Unable to read the uploaded file");
    return;
    }//end of try-catch
    }//end of if
    showing the following errors
    15:36:47,339 ERROR [MultiPartRequest] org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (2264141) exceeds the configured maximum (2097152)
    15:36:52,839 ERROR [FileUploadInterceptor] the request was rejected because its size (2264141) exceeds the configured maximum (2097152)
    please any one help me
    sreenu
    Thank You

    I looked at the sample code, (getCategory() == null ). I wasn't sure if it's ok for me to validate the contentType sheet in the ActionForm, it's not a String. I moved the validation to the Action after its not working. I placed the code back to the ActionForm and debugged the code and ti worked. Thanks.

  • Cannot upload file suddenly

    Hi
    I built a code to upload file and create directory. It did work yesterday. When I run it today, the file cannot be uploaded.
    <input type="file" name="myimage">
    enctype="multipart/form-data"
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if(isMultipart)
    DiskFileItemFactory factory = new DiskFileItemFactory(); //I added a breakpoint here, Source not found for WebappClassLoader.loadClass(String)               
    factory.setSizeThreshold(500000);               
    factory.setRepository(tempPathFile);
    ServletFileUpload upload = new ServletFileUpload(factory);
    upload.setSizeMax(1000000);     
    List /*FileItem*/ items = upload.parseRequest(request);
    Iterator /*FileItem*/ i = items.iterator();
    Why this happen?

    Ok "cannot be uploaded" is rather unspecific. What happens? Does your browser prevent you from pressing the "Upload"-Button? Are aliens intercepting your data? Do you get an exceptions? An error message? Anything?

  • Cannot upload file to TFTP on Subscriber

    All,
    I have an 8.5 cluster (pub and sub). I'm trying to upgrade the phone firmware for one phone by uploading a file to tftp.
    I can upload the zip file successfully to the pub, but when I try the same thing on the sub in OS Administration, I get 'Waiting for response from <sub IP>'
    in the status bar of the Upload File dialog box, and stays that way, never uploads.
    DB status is good, 2 on both boxes. TFTP service started on both servers.
    The other odd thing is that i can restart services for both servers from the pub, but when i try to restart services on the pub from the sub i get an error message that i cannot connect to the remote node (pub).
    Any thoughts?
    Thanks,

    I am not quite sure if what you are doing is a special requirement but generally for upgrading phone firmware, you need to download the COP file from CCO and use the Install/Upgrade drop down from CUCM, starting with Publisher and then the subscirber.
    Usually the error message states that their is a Tomcat certificate issues between the Pub/Sub. You should be able to go directly to the sub and restart the service. To fix the issue, is the Tomcat cert signed by a 3rd party CA, if yes then it will have to resigned. If its not, the Tomcat certificate will have to be regenerated and Tomcat service restart. This could also happen if you have a user with UserID administrator.
    Please rate useful posts.

  • Add internal bluetooth module for Probook 5310m, cannot receive files

    Hi, I tried to add internal bluetooth module for my probook 5310m, which should be very similar to 4311s and 5320m.
    I did installed the module and cable by following the maintenance guide, but there is something wrong about the driver so I cannot receive files through bluetooth from either my smartphone or my another laptop. My phone showed " The transfer is forbidden by the target device( which means 5310m)". 
    The bluetooth module I got is Broadcom 2070 bluetooth 3.0. My operation system is windows 7 ultimate 32. I tried driver package sp52773 and some earlier version but none of them works. I even let windows update drivers by itself, it still did not work. The only good part is my bluetooth headphone works perfectly and I can sent stuff out from my 5310m. Does anyone know how to fix this problem? I really want to fix this since I use bluetooth a lot. I will really appreciate your help.
    Thank you again.
    Jing

    I found a way to fix this problem. I install the bluesoleil software and everything works fine finally. Thank god.

  • My ipad cannot receive files either through bluetooth or USB. Pls i need assistance

    My ipad cannot receive files either through bluetooth or USB. Pls heep me out

    You can use iTransfer to transfer photos and Music via Bluetooth between iDevices.
    https://itunes.apple.com/sg/app/itransfer-share-files-ease/id480195086?mt=8

  • Gnome-Bluetooth cannot receive files from Nokia Lumia 810

    To whom it may concern,
    I opened a  bug report stating that I cannot receive files from my Nokia Lumia 810 using gnome-bluetooth. According to Nokia, it should be able to (and they claimed they tested it themselves during my phone call with them). The bug report is FS#33348. I'd appreciate if anyone could assist me on this problem.

    jainkkunal wrote:
    This link has been deleted could you please post the solution here Thanks in anticipation
    Hi and Welcome to the Forums!
    See this KB:
    KB05409 Transfer a file using Bluetooth technology between two BlackBerry smartphones
    Substitute, in the KB, the appropriate instructions for your other device in place of the KB section for the sending device. Do not skip the "Receive Using BT" step on the receiving BB...nothing will transfer if you do.
    Good luck and let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for