×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    14

    HTTP POST fails with Error Status = -20019

    Everytime I try to perform an HTTP POST on the Series 60 emulator and 3650 device I get the following Exception:

    java.io.IOException: Status = -20019
    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)


    Here is my code snippet:

    c = (HttpConnection)Connector.open(myurl);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("Authorization", auth);
    c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    OutputStream out = c.openOutputStream();
    out.write(abyData);
    out.flush();
    in = c.openInputStream(); // exception is thrown here!


    The actually request does go through on the server, and the server returns the correct response (according to the web server logs), but I am unable to read it because the exception is thrown.

    Does anyone know what Status = -20019 is?

    Thank you.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1
    Hi, I'm also having an exact problem and it seems to me that eventhough your sending the request as POST it is still interpreted or sent as a GET method. If you would try to append the query string to your url and still set the request to POST, you'll see that it will actually act as GET. As of now I'm still searching for the proper way to do this.

    Cheers!

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    14
    When I look at the server logs the server is definetly getting the request as a POST, even if I put query parameters on the url as well as the body (which is allowed in a POST). From the server side the request works fine, the request is received by the server correctly, it's only the client side that cannot read the post response.

    As a temporary workaround I had to proxy the POST request over a GET request, since there was no way I could get a POST working. I know it's a very back fix, but it's the only way to make it work for now.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    5
    I also am having the same trouble, although only on a nokia 7650 so far. It's incredibly frustrating! The request makes it to the server perfectly intact it seems, the proper response (at least for me) is also returned. I've traced this with a packet sniffer whilst running the series 60 emulator.

    The point of failure that I can see is the HttpConnection (gprs connection?). I've instantiated an OutputStreamWriter object and used this to write to the server. When that's all finished, I call the Close() method on the object in order to subsequently open an InputStreamReader to read off the response. It's at this point that the exception is thrown. An IOException with a message of "Status = -20019". If this is ignored, subsequent activity on the HttpConnection throws further exceptions citing "unexpected end of stream".

    As far as I can see, it's a poor implementation of these objects, or the interaction between the objects and the underlying connection architecture. They simply don't work as they should, and it's not isolated to just myself, else I'd assume I was using them incorrectly. I haven't tried alternate methods to write/read data yet, though I will, but I just don't want to because it works on every other phone/emulator I've tested with. So I'll assume this to be the case until I hear different (from nokia would be nice)..

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    101
    If you're having networking problems, you should try some third-party MIDlets known to work with your device to help narrow the issue down. If those MIDlets also fail, then it's likely a problem with your connection settings rather than your code.

    Reqwireless WebViewer is one MIDlet that works well on the Nokia 3650 and 7650.

    If you're using a WAP access point on the Nokia 3650 or 7650, you should try switching to an Internet access point.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Location
    Maastricht, The Netherlands
    Posts
    21

    Ohhhhhhhh YEAAAAAHAHHHHHH!!!!!!

    First of all: LiamQ quit placing adds for your own company, it's irritates me A LOT!

    Oke guys I had the same problem as you! And after a couple of hours with my computer maybe I've the solution!

    The big question is: Do you call the method that creates the connection from another Thread? I did, and my problem was probably that the same Thread called the method again! But connection from the first call was still open... voila an error (No wonder)

    What did I do? I made the method that creates the connection 'synchronized' and all my following tests where succesfull!

    a very small code snippet:
    Code:
    public synchronized String send(String question, int chunk) {
      String data = new String(question);
        try {
          if(serverURL != null) {
            connection = (HttpConnection) Connector.open(serverURL);
            connection.setRequestMethod(HttpConnection.POST);
            OutputStream output = connection.openOutputStream();

  7. #7
    Registered User
    Join Date
    Mar 2003
    Location
    Maastricht, The Netherlands
    Posts
    21

    :(

    Sorry, sorry I celebrated to soon

    No I still have the problem... but a lot less then in the beginning! Maybe somebody else still got some other idea's?

  8. #8
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    101
    Hi guidopater,

    I'm sorry for offending you. My intention was to help, not to advertise. There are lots of potential pitfalls in networking on the 7650 due to bugs and connection settings. Since WebViewer dances around the 7650 bugs, trying it is a good way to test whether the issue is with connection settings or the MIDlet's code.

    In the future, I'll avoid helping where it may be considered as advertising.

  9. #9
    Registered User
    Join Date
    Mar 2003
    Location
    Maastricht, The Netherlands
    Posts
    21
    Oke now I offended you (I think) don't take it so serious!

    But when I browsed the forum I ran into the same message for 5 times or so

    If you're having networking problems, you should try some third-party MIDlets known to work with your device to help narrow the issue down. If those MIDlets also fail, then it's likely a problem with your connection settings rather than your code.

    Reqwireless WebViewer is one MIDlet that works well on the Nokia 3650 and 7650.

    If you're using a WAP access point on the Nokia 3650 or 7650, you should try switching to an Internet access point.
    I also tried your program and it's pretty cool... but in this kind of problems the phone connection works just fine, only something in the source is wrong... And unless we have the source of WebViewer, this program will not solve our problems!

    So Sorry, maybe I was just to irritated about my own programmingskills

    BUT keep up the good work...

  10. #10
    Registered User
    Join Date
    May 2003
    Posts
    5
    I also tried the webviewer midlet, with some degree of success, at least now my target phone appears to be correctly set up with internet/gprs settings as I got this to work. Helpful! I also agree however that it's kinda pointless without the source

    My HttpConnection calls have not to date been multithreaded, so I'm sure that's not the problem where I'm concerned, I may try getting them to be so today, see if it helps. Can't say I hold out much hope though to be honest.

  11. #11
    Registered User
    Join Date
    Mar 2003
    Posts
    16
    Looks like, with some subscriptions (like standard orange france subscribers have) you have to go through a wap gateway.

    In this case, I have experienced that WebViewer does not work on a 7650, although other midlets do work. As you point, we don't have the source code of Web Viewer, so I can only guess that it may be a problem with wml headers.

    Thus : if WebViewer works, then we can assume that your connection settings are OK. If WebViewer does not work, that does not mean that your connection settings are not OK.

    Moreover, I have experienced also that with orangemib, using the wap gateway rather than 0.0.0.0 greatly enhances performances when doing repeated requests to the same url.

  12. #12
    Registered User
    Join Date
    Mar 2003
    Location
    Maastricht, The Netherlands
    Posts
    21
    I'm testing on the gateway of Vodafone! The problem I experience is that I must use the gateway in order to contact a site on the internet (Vodafone is very smart) ...

    So I've to use the gateway connection and cannot change my gateway ip to 0.0.0.0!?

    Today I will test a little bit more with the Nokia, but I've also some problems with the Sharp GX-10! But if I discover something, you'll hear it from me...

    Greetz

  13. #13
    Registered User
    Join Date
    May 2003
    Posts
    5
    Using Vodafone,

    The only way I could get the WebViewer midlet to work is by using the vodafone internet/gprs settings. ie

    GPRS APN : internet
    username : web
    password : web

    There should be a gateway IP defined also, but following most advice on webpages found from browsing around, I couldn't get it to work with that. I used 0.0.0.0 and it worked. My program however didn't, so it's back to the drawing board.

  14. #14
    Registered User
    Join Date
    Mar 2003
    Location
    Maastricht, The Netherlands
    Posts
    21

    Code exchange

    Post a part of your sourcecode! Than we can compare it and maybe find something diverent... what kind of software version of Nokia do you use (presse "*#0000#" on your phone)?

    This is my code example:
    Code:
    public synchronized String send(String data) { 
      try {
        if(serverURL != null) {
        connection = (HttpConnection) Connector.open(serverURL);
        connection.setRequestMethod(HttpConnection.POST);
        OutputStream output = connection.openOutputStream();
    
        output.write(data.getBytes());
        output.write(-1);
        output.flush();
        output.close();
    
         InputStream input = connection.openInputStream();
         int contentLength = (int)connection.getLength();
         if(contentLength < 1) contentLength = 4096;
         byte[] raw = new byte[contentLength];
         int length = input.read(raw);
    
         // CLOSE the connection
         input.close();
         connection.close();
         input = null;
         output = null;
         connection = null;
         String response = null;
    
         response = new String(raw,0 , length);
    }

  15. #15
    Registered User
    Join Date
    Mar 2003
    Posts
    12
    Hi,

    I had some similar problem with HttpConnection (POST) on 3650, and the same error: -20019 or -20015 ...

    I fixed the problem by changing the port my server listen on : when it is listenning on port 9710, it doesn't work. But with port 80 it works fine.

    I think it comes from a GPRS provider's problem (Orange must forbid every HttpConnection on port different than 80)

    hope it will help some of you.

    Niko

Posting Permissions

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