×

Discussion Board

Results 1 to 3 of 3

Thread: Xmlrpc

  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    IL/USA
    Posts
    341

    Xmlrpc

    Hello,
    I am using kxmlrpc from http://kxmlrpc.objectweb.org/ and I am getting the following error;
    Code:
    java.io.IOException: Persistent connection dropped after first chunk sent, cannot retry
    	at com.sun.midp.io.j2me.http.Protocol.sendRequest(+102)
    	at com.sun.midp.io.j2me.http.Protocol.writeBytes(+61)
    	at com.sun.midp.io.BaseOutputStream.write(+49)
    	at java.io.OutputStream.write(+8)
    	at org.kxmlrpc.XmlRpcClient.execute(+160)
    I am posting a struct and it's contains Base64 encoded picture. Any idea what this error is and how to fix it? I'm testing on Sun WTK EMU. I do have internet connectivity because I am able to talk to site using other XMLRPC commands.



    Thanks,

  2. #2
    Registered User
    Join Date
    Nov 2003
    Posts
    31

    Re: Xmlrpc

    This reply may be a year late, but better late than never....

    Did you get it fixed?

    Without seeing the code, it's hard to tell why you are getting this error.
    What is the size of the file you are sending? Do you get the same error on a tiny file size?
    Can you post the code?

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    22

    Re: Xmlrpc

    Hello,
    I also get the exact same error.
    When I upload a file, the upload works.
    The file is over 2KB, around 50KB or bigger usually (a picture).

    However, after 180 seconds exactly I get the error mentioned above.
    The file DOES get upload via the emulator. On my E61 I don't get this timeout, the file goes up straight. However, on my Navigator 6110 the file doesnt upload at all!

    I will show the code below. I am totally confused with this, very difficult to fix something that seems to happen on phones and not others. Perhaps my problem is in my code. Please have a look.

    The server is using http1.1, hence the upload gets chunked automatically.

    I think my http constructs are correct, since the file upload on my phone and emulator, but it timeout on emulator, throws error and then file is uploaded. On the navigator it doesnt work at all.

    Thanks for the help!


    --------------------------------------------

    String boundary = "B1O2U3N4D5A6R7Y";
    String boundaryMessage = "--" + boundary + "\r\n"
    + "Content-Disposition: form-data; "
    + "name=\"upfile1\"; filename=\""
    + fn + "\"\r\n"
    + "Content-Type: " + "application/octet-stream" + "\r\n"
    + "\r\n";
    String endBoundary = "\r\n" + "--" + boundary + "--" + "\r\n";

    byte[] endBoundaryBytes = endBoundary.getBytes();
    byte[] boundaryMessageBytes = boundaryMessage.getBytes();

    try {

    FileConnection fc = (FileConnection) Connector.open("file:///"+fileName,Connector.READ);

    InputStream is = fc.openInputStream();
    long overallSize = fc.fileSize();

    int cl = boundaryMessageBytes.length + (int)overallSize + endBoundaryBytes.length;

    String cl2 = Integer.toString(cl);

    httpCon = (HttpConnection) Connector.open(urlstring,Connector.READ_WRITE,false);
    httpCon.setRequestMethod(HttpConnection.POST);
    httpCon.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
    httpCon.setRequestProperty("Content-Type", "multipart/form-data; boundary=B1O2U3N4D5A6R7Y");
    httpCon.setRequestProperty("Keep-Alive","10");
    httpCon.setRequestProperty("Connection","keep-alive");
    httpCon.setRequestProperty("Content-Length", cl2);
    httpCon.setRequestProperty("Connection","Close");

    dos = new DataOutputStream(httpCon.openDataOutputStream());

    for(int i=0;i<boundaryMessageBytes.length;i++) {
    dos.writeByte(boundaryMessageBytes[i]);
    }

    int ch;
    int ii = 0;
    while ((ch = is.read()) != -1) {
    ii = ii +1;
    int b = (ch & 0x000000FF);
    dos.writeByte(b);
    }
    }

    for(int i=0;i<endBoundaryBytes.length;i++) {
    dos.writeByte(endBoundaryBytes[i]);
    }


    dos.flush();

    dos.close();

    is.close();

    fc.close();

    httpCon.close();


    } catch (IOException ex) {
    System.out.println("IOException");
    ex.printStackTrace();
    } catch(SecurityException sex){
    System.out.println("Security Exception");
    sex.printStackTrace();
    } catch (Exception ex) {
    ex.printStackTrace();
    } catch (OutOfMemoryError oomer) {
    System.out.println("Out OF Memory Exception");
    oomer.printStackTrace();
    } finally {
    try {
    if (dos!=null) {
    dos.close();
    }
    if (httpCon!=null) {
    httpCon.close();
    }
    } catch (IOException ex) {
    ex.printStackTrace();
    }

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×