You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old HTTP POST fails with Error Status = -20019 - 2003-04-24, 17:46

Join Date: Apr 2003
Posts: 14
pauldumais
Offline
Registered User
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.
Reply With Quote

#2 Old 2003-05-15, 04:50

Join Date: May 2003
Posts: 1
rrcarreon
Offline
Registered User
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!
Reply With Quote

#3 Old 2003-05-15, 15:34

Join Date: Apr 2003
Posts: 14
pauldumais
Offline
Registered User
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.
Reply With Quote

#4 Old 2003-05-15, 17:31

Join Date: May 2003
Posts: 5
nooro
Offline
Registered User
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)..
Reply With Quote

#5 Old 2003-05-16, 05:27

Join Date: Mar 2003
Posts: 101
Location: Canada
LiamQ
Offline
Regular Contributor
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.
Reply With Quote

#6 Old Ohhhhhhhh YEAAAAAHAHHHHHH!!!!!! - 2003-05-27, 20:34

Join Date: Mar 2003
Posts: 21
Location: Maastricht, The Netherlands
guidopater
Offline
Registered User
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();
Reply With Quote

#7 Old :( - 2003-05-27, 21:03

Join Date: Mar 2003
Posts: 21
Location: Maastricht, The Netherlands
guidopater
Offline
Registered User
Sorry, sorry I celebrated to soon :D

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

#8 Old 2003-05-28, 01:19

Join Date: Mar 2003
Posts: 101
Location: Canada
LiamQ
Offline
Regular Contributor
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.
Reply With Quote

#9 Old 2003-05-28, 09:34

Join Date: Mar 2003
Posts: 21
Location: Maastricht, The Netherlands
guidopater
Offline
Registered User
Oke now I offended you :D (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

Quote:
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 :D

BUT keep up the good work...
Reply With Quote

#10 Old 2003-05-28, 09:52

Join Date: May 2003
Posts: 5
nooro
Offline
Registered User
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.
Reply With Quote

#11 Old 2003-05-28, 11:31

Join Date: Mar 2003
Posts: 16
gerodol
Offline
Registered User
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.
Reply With Quote

#12 Old 2003-05-28, 11:36

Join Date: Mar 2003
Posts: 21
Location: Maastricht, The Netherlands
guidopater
Offline
Registered User
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
Reply With Quote

#13 Old 2003-05-28, 11:48

Join Date: May 2003
Posts: 5
nooro
Offline
Registered User
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.
Reply With Quote

#14 Old Code exchange - 2003-05-28, 16:30

Join Date: Mar 2003
Posts: 21
Location: Maastricht, The Netherlands
guidopater
Offline
Registered User
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);
}
Reply With Quote

#15 Old 2003-05-28, 16:32

Join Date: Mar 2003
Posts: 12
Send a message via ICQ to niko86
niko86
Offline
Registered User
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
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia