×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    "java.io.IOException: Status = -20019" when trying to get a response code

    Hi.
    First of all some background. I'm developing a client/server app with J2ME, using Nokia's Toolkit for Symbian. I do frequent polling with HTTP requests using an HttpConnection.
    When I start running the application, it works well. However, sooner or later the connection somehow fails. The following exception is thrown:
    java.io.IOException: Status = -20019
    when I try to get the response code with the following line:
    status = c.getResponseCode(); (c is the HttpConnection object)
    What's really strange is that when I check the web server's log, I can see that the connection was made, and according to the logs the response code is 200. But this isn't reaching back the MIDlet, like I said, an IOException is thrown when I try getting the response code.
    Does anyone know the meaning of the above mentioned exception?
    I must add that I am running two emulators (EPOC32) simultaneously, and one of them is always polling the server for updates (and I suspect this might have something to do with it).

    [edit]
    Upon closer inspection of the server's logs, I realized that the requests aren't reaching the server. Can anyone tell me why the Connection would suddenly stop working? Even if I make some retrys after catching this exception, the connection doesn't come back.
    [/edit]

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    14

    Error -20019 every time I POST

    Have you found a solution to your problem?

    I get the same error -20019 everytime I do a POST on the Series 60 emulator and real device.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    43
    I am also having this problem. At first the connection works fine, but after a certain number of times, I get an IOException with status = either -33 or -20019. It is like the phone's ability to open an HTTP Conncetion just stops or gets tired out for no reason. Anyone have any ideas?

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    12
    I don't know if you had answers but perhaps this will help you:

    I had some problem with HttpConnection on 3650... 'status = -20019' or '20015' ... even if it was working fine on the emulators...

    I did two things:
    - recommended by Nokia's expert: make your httpconnection in a separate thread.

    - by chance I found this, supposing my GPRS provider didn't say everything to me !
    I changed the port of my server (to which I sent POST from my MIDlet): my provider, I guess, was dropping all messages not destinated to port 80 ... (mine were going to port 9710, and this wasn't wortking). On port 80, everything is working fluently !

    hoep it will help you


    Niko

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    14
    I am doing all connections in a seperate thread, as well they are all on port 80. GET connections work fine for me, it is POST connections that always fail, has anyone else been able to do a POST using the 3650?

  6. #6
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Oldenburg, Germany
    Posts
    118

    Finally, a solution for IOException -20019

    Hi,

    we finally found a solution for the IOException -20019 problem!
    The trick is that the IIS 5.x server sends after a POST (not after GET!) request always a "100 continue" package. Tomcat (for example) but sends always "200 ok". Our MIDlet works with Tomcat as server without any problems, NO IOExceptions!!

    Our team on the server-side developed a ISAPI-Filter to avoid the "100 continue" package.
    Since then our MIDlet has NO problems with http connection on the emulator and the real device!

    Regards,
    Sebastian Szczygiel
    Last edited by sebflash; 2003-09-08 at 14:25.

  7. #7
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Beijing/China
    Posts
    153
    Hi, all

    I am also having this problem.
    Server side:
    1) IIS 5.x service at port 80, CGI;
    MIDlet:
    1) request method: GET;
    2) do the http request in a separate thread;
    Result:
    1) get IOException: status = -20019 with emulator from Series_60_MIDP_SDK_for_Symbian_OS_v_1_0
    2) the same Exception on Nokia 3650 (V 2.20) and Nokia 7650(V4.34)
    3) works well on emulator comes with Series_60_MIDP_Concept_SDK_Beta_0_3_Nokia_edition

    I can visist "http://www.javacourses.com/cgi-bin/getgrade.cgi?idnum=182016" with the same code.
    The head field "server" is Apache/1.3.27 (Unix) FrontPage/4.0.4.3 PHP/4.3.1 mod_fastcgi/2.2.8.
    So I think the problem may comes from:
    1) server side;
    2) implements of request operation in the KVM;
    But I get no idea to deal with it. Maybe I should try it on a Apache server.
    Last edited by Steven_Ch; 2003-09-09 at 06:53.

  8. #8
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Oldenburg, Germany
    Posts
    118
    The Problem is on the server and client side! But it can only be fixed on the server ! Try Tomcat as server and send your request again, you'll see, it works then! Or check first if your server is sending a "100 continue" package after a request.

    This bug is only in the MIDP implementation for Series 60.

    Regards,
    Sebastian Szczygiel

  9. #9
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Beijing/China
    Posts
    153
    sebflash

    I've moved the cgi to Apache HTTP Server 2.0.47.
    It do works well now.
    Thx.

    Regards,
    Steven Chang

  10. #10
    Registered User
    Join Date
    May 2003
    Location
    Tropical Paradise Penang
    Posts
    43

    Please help

    I'm using WTK104 with Series 60 device emulator. When I trying to connect to my Tomcat/Resin web server, i got this error:

    c= com.symbian.midp.io.protocol.http.Connection@1cb37664
    java.io.IOException: Status = -20028
    at com.symbian.cldc.connection.ConnectionEndPoint.writeBytes(+140)
    at com.symbian.cldc.connection.OutputStream.flush(+23)
    at com.symbian.midp.io.protocol.http.HttpConnection.sendRequest(+101)
    at com.symbian.midp.io.protocol.http.HttpConnection.ensureResponse(+40)
    at com.symbian.midp.io.protocol.http.HttpConnection.openDataInputStream(+15)
    at com.symbian.midp.io.protocol.http.HttpConnection.openInputStream(+4)
    at example.http.HttpTest.readContents(+154)
    at example.http.HttpTest.commandAction(+34)
    at javax.microedition.lcdui.Displayable.commandAction(+29)
    at javax.microedition.lcdui.Toolkit.postEvent(+78)
    at com.symbian.midp.compatibility.runtime.KVMEventProcessor.run(+27)
    class java.io.IOException
    java.io.IOException: Status = -20028
    Exception reading from http
    java.io.IOException: Unexpected end of stream
    at com.symbian.midp.io.protocol.http.HttpConnection.throwIOException(+8)
    at com.symbian.midp.io.protocol.http.HttpConnection.readLine(+54)
    at com.symbian.midp.io.protocol.http.HttpConnection.readStatusLine(+5)
    at com.symbian.midp.io.protocol.http.HttpConnection.getResponse(+10)
    at com.symbian.midp.io.protocol.http.HttpConnection.ensureResponse(+44)
    at com.symbian.midp.io.protocol.http.HttpConnection.getResponseMessage(+8)
    at example.http.HttpTest.readContents(+516)
    at example.http.HttpTest.commandAction(+34)
    at javax.microedition.lcdui.Displayable.commandAction(+29)
    at javax.microedition.lcdui.Toolkit.postEvent(+78)
    at com.symbian.midp.compatibility.runtime.KVMEventProcessor.run(+27)
    java.io.IOException: Unexpected end of stream

  11. #11
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Oldenburg, Germany
    Posts
    118
    Post the code!

    Regards,
    Sebastian Szczygiel

  12. #12
    Registered User
    Join Date
    May 2003
    Location
    Tropical Paradise Penang
    Posts
    43

    Thank you for replying

    Actually I'm using the demo example from Sun included in WTK104. It's in /home/WTK104/apps/demo included in WTK104.

    The error that I get is when I use Series_60_MIDP_SDK_for_Symbian_OS_v_1_0 & 1_2. It always prompt me to select "Direct Http" before I can get the connection.

    Nonetheless, I try to write the simplest direct http connection code & still gave me the same problem:
    Code:

    /****** TestHttp.java *******/
    package test;

    import java.io.*;
    import java.util.*;
    import javax.microedition.io.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;

    public class TestHttp
    extends MIDlet
    implements CommandListener {

    Display display;
    Form myForm;
    TextField tfURL = new TextField("URL", "http://", 150, TextField.URL);

    public TestHttp() {
    display = Display.getDisplay(this);
    }

    protected void destroyApp(boolean p1) throws MIDletStateChangeException {
    }

    protected void pauseApp() {
    }

    protected void startApp() throws MIDletStateChangeException {
    initForm();
    }

    public void commandAction(Command c, Displayable d) {
    if (c.getLabel().indexOf("POST") > -1) {
    sendPost();
    }
    }

    void initForm() {
    myForm = new Form("Test URL");
    myForm.setCommandListener(this);
    myForm.addCommand(new Command("POST", Command.OK, 0));
    myForm.append(tfURL);

    display.setCurrent(myForm);
    }

    void sendPost() {
    HttpConnection c = null;
    try {
    c = (HttpConnection)Connector.open(tfURL.getString());
    c.setRequestMethod( HttpConnection.POST );
    c.setRequestProperty( "User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0" );
    c.setRequestProperty( "Content-Language", "en-US" );
    c.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" );//very important for submitting post
    InputStream inStream = c.openInputStream();

    String sb = "Http Not OK";
    if (c.getResponseCode() == HttpConnection.HTTP_OK) {
    int ch;
    StringBuffer buffer = new StringBuffer();
    while ( (ch = inStream.read()) != -1) {
    buffer.append((char)ch);
    }
    sb = buffer.toString();
    }
    myForm = new Form("Result");
    myForm.append(sb);
    }
    catch (Exception e) {
    e.printStackTrace();
    myForm.append("Error:" + e.getMessage());
    }
    finally {
    try {
    if (c != null) c.close();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }
    display.setCurrent(myForm);
    }

    }

    /***** End *****/



    Result:
    java.io.IOException: Status = -20028
    at com.symbian.cldc.connection.ConnectionEndPoint.writeBytes(+140)
    at com.symbian.cldc.connection.OutputStream.flush(+23)
    at com.symbian.midp.io.protocol.http.HttpConnection.sendRequest(+101)
    at com.symbian.midp.io.protocol.http.HttpConnection.ensureResponse(+40)
    at com.symbian.midp.io.protocol.http.HttpConnection.openDataInputStream(+15)
    at com.symbian.midp.io.protocol.http.HttpConnection.openInputStream(+4)
    at test.TestHttp.sendPost(+60)
    at test.TestHttp.commandAction(+17)
    at javax.microedition.lcdui.Displayable.commandAction(+29)
    at javax.microedition.lcdui.Toolkit.postEvent(+78)
    at com.symbian.midp.compatibility.runtime.KVMEventProcessor.run(+27)



    The same error code.

  13. #13
    Regular Contributor
    Join Date
    Aug 2003
    Location
    Oldenburg, Germany
    Posts
    118
    Can you connect to your server (or servlet) from a browser?

    Regards,
    Sebastian Szczygiel

  14. #14
    Registered User
    Join Date
    May 2003
    Location
    Tropical Paradise Penang
    Posts
    43
    Yes, I can connect to my servlet from my browser. In fact I even try to connect using Sun's example to yahoo.com, but I still got the error in the emulator. However when I load it inside my phone, it works perfectly.

  15. #15
    Registered User
    Join Date
    Mar 2003
    Posts
    7

    Tomcat

    Interesting that a switch to tomcat fixed the -20019 problem for some people. We have been runnning tomcat all the time but are still getting this exception. Are currently running tomcat 5.0.16 but have had the same problem on older versions as well.

    Anybody have any more ideas?

Posting Permissions

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