×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    14

    6600 HTTP Post hang

    Hi

    has anyone managed to get network connectivity in MIDP2 yet?

    I have ported a MIDP1 application over to the 6600 without too many problems except when the app connects to a server (sending a HTTP Post) in a way that works fine for MIDP1, nothing is ever received at the server end. (WAP settings are fine, have double checked with another Nokia on the same network running MIDP1)

    This is not an error that's mentioned in the known issues PDF from Nokia, was wondering if anyone else came accross the same.

    thanks

    eric

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    3
    Hi Eric.

    I have found that using the flush() method on the outputstream when sending data from the midlet to a servlet will result -1 as Content-Length at the servlet doPost method.
    Than not use the flush() only the close() on the outputstream.
    It works fine on 6600 for me.

    Regards,
    Agnes

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    14
    Thanks Agnes,

    I checked my code and I'm not using flush() - none the less the fact that you have managed to get network connectivity using your 6600 gives me hope!

    I'm starting to think that the problem could be the gateways as I have some pre-installed symbian applications from CNN and FT on my 6600 that have also never managed to get a connection. (I've tried Vodafone and O2 in the UK, using their respective SIMs).

    The gateway issue gave me a lot of angst when I started coding for MIDP 1 as some WAP gateways aren't set up to accept network connections from Java applications, even if they can provide access through regular WAP browsers, and it's just a matter of trial and error to get gateway settings that work. I also wonder if the automated wap settings provider that I'm using hasn't got their over the air configuration settings wrong for the nokia 6600 (https://secure.mouse2mobile.com/clie...m/wap/1dis.asp)

    I've detailed the code below in case anyone can spot anything (it works fine in MIDP 1), and anyway some might find it useful.

    thanks again Agnes, and please let me know if you spot anything wrong with my code

    eric


    HttpConnection conn = (HttpConnection)Connector.open(url);

    //set the request method and headers
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
    conn.setRequestProperty("Content-Language", "en-GB");
    conn.setRequestProperty("If-Modified-Since", "29 Oct 1999 19:43:31 GMT");
    //this normally happens anyway, but some implementations get it wrong apparently
    conn.setRequestProperty ("Content-Length", ""+request.length());

    //getting the output stream can flush the headers
    OutputStream out = conn.openOutputStream();

    int requestLength = request.length();

    for (int i=0; i<requestLength; ++i){
    out.write(request.charAt(i));
    }

    if (conn.getResponseCode()==HttpConnection.HTTP_OK){//code = 200

    //-------------------------------application hangs just here :(

    InputStream in = conn.openInputStream();
    //Get the length and process the data
    StringBuffer responseBuf;
    long length = conn.getLength();
    if (length>0){
    responseBuf = new StringBuffer((int)length);
    } else {
    responseBuf = new StringBuffer(); //default length
    }
    int ch;
    while ((ch=in.read()) != -1){
    responseBuf.append((char)ch);
    }
    responseStr = responseBuf.toString();
    }

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    3
    Hi Eric,

    I can't spot anything wrong with your code. The code which I'm using almost the same.

    Simplified client side code:
    --------------------------------
    HttpConnection conn = (HttpConnection)Connector.open(ServletURL);
    conn.setRequestMethod(HttpConnection.POST);
    conn.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
    String locale = System.getProperty("microedition.locale");
    if (locale == null)
    locale = "en-US";
    conn.setRequestProperty("Accept-Language", locale);
    conn.setRequestProperty("Content-Type","application/octet-stream");
    conn.setRequestProperty("Accept","application/octet-stream");

    byte[] requestdata = ...

    OutputStream out = conn.openOutputStream();
    conn.setRequestProperty("Content-Length",""+requestdata.length);
    out.write(requestdata);
    out.close();
    out = null;

    if (conn.getResponseCode()!=HttpConnection.HTTP_OK)
    throw new IOException("Bad response code");

    InputStream in = conn.openInputStream();
    int n = (int)conn.getLength();
    byte[] responsedata = new byte[n];
    int m = in.read(responsedata);
    in.close();
    in = null;

    Simplified server side code:
    ----------------------------------
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    {
    ...
    byte[] replydata = buffer.toString().getBytes(CHARSET_NAME);
    response.setContentType("application/octet-stream");
    response.setContentLength(replydata.length);
    OutputStream out = response.getOutputStream();
    out.write(replydata);
    out.flush();
    ...
    }

    Maybe it will be useful.
    Agnes

  5. #5
    Registered User
    Join Date
    Oct 2003
    Posts
    14
    Just to update you on what's happened.

    Eventually my network provider (Genesis on behalf of O2 in the UK) gave up trying to help and said I should contact Nokia giving me a number that didn't even work.

    But I have finally managed it - it was indeed the network operator settings - (that the operator didn't even seem to know about).

    If you're in the UK also and are having this problem, you want the Web settings for your network as described on this very useful page: http://www.filesaveas.com/gprs.html

    All the best

    Eric

  6. #6
    Registered User
    Join Date
    Dec 2003
    Posts
    6

    6600

    eric, for the 6600 there doesn't appear to be a Gateway setting, are you just using the "Proxy Server" field instead?

  7. #7
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    Hi,
    I have the same problem you've described above.
    But, unfortunately, I'm in Germany, not in UK, so I can't use the settings you provided.
    I have the WAP GPRS settings also from the official NOKIA site.
    So... what was the difference in your settings? The proxy address?
    I see on the server that when I send a request from the Nokia7650, the request comes from the gateway address. But for Nokia 6600, the request comes directly from the phone address. And hangs...
    Can you help me?

    Daniela

  8. #8
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    Hi again,
    This should be of help to the UK O2 people, and might be of use to you Daniela.

    We did a little research into the O2 gateway, and by the looks of it, it's quite badly out of date. I believe it doesn't even support WAP2, which is the only standard the 6600 DOES support! We have tried our application on countless other networks, all of which are fine. Our new company moto is "Blame O2".

    Daniella, it might be worth looking into whether your providers gateway is compliant with the 6600.

    sorry i didn't come forward with this earlier. hope it helps.

  9. #9
    Registered User
    Join Date
    Oct 2003
    Posts
    14
    Splog -

    quite possibly is the "Proxy Server" field. I don't have the Nokia 6600 to hand any more so I can't tell you. When I get hold of it I'll check.

    Daniela -

    J2ME (and Symbian) applications on the Nokia 6600 don't use "WAP APN" settings for communication (unlike every other J2ME phone I've ever come accross). Instead they need "Internet APN" settings. (I don't know what the technical difference is - anyone?) If you are using the automatic configuration service from Nokia here: https://secure.mouse2mobile.com/clie...m/wap/1dis.asp
    they will give you "WAP APN" settings.

    To find out your "Internet APN" settings, you will need to ask your network provider. As an example, in the UK the "Internet APN" and "WAP APN" settings for the Orange network are exactly the same except in the APN field you must type "orangeinternet" instead of "orangewap"

    Sorry I can't help with the actual settings but at least you now know what to ask for from your network.

    eric

  10. #10
    Registered User
    Join Date
    Oct 2003
    Posts
    14
    Just to clarify, when I talk about "Internet APN" settings, that's what on this link http://www.filesaveas.com/gprs.html they call GPRS settings (Email/Web) (and I think they have the username and password wrong for orange GPRS settings (WAP) in my experience, you should use no username and no password for orange in the UK - same as GPRS settings (Email/Web)).

    And another thing The Nokia 6600 does seem to just hang when there is a network problem, rather than throwing an exception so it's difficult to handle it.

  11. #11
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    yeah, we encountered the hanging problem. i believe it's caused by the 6600's lack of timeout on communications. Which, combined with networking blocking in java, makes it a right pain.

  12. #12
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    I've tried both: WAP GPRS settings and mobile Internet settings.
    In both cases, the HTTP Post reaches the server, but ... hangs. I use tcptrace to see the traffic and I can see that the server answes correctly, but the status of the connection stays on "connected" a very long time.
    The interesting thing about Nokia 6600 is that the request comes directly from phone ( I see the IP address of the phone), different from Nokia 7650, where the requests are forwarded by a gateway and arrive on server with the IP address of the gateway.

  13. #13
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    yep, that's exactly what we encoutered, dany. We found that the server was recieving http1.0 data, despite us setting it to http1.1. it's very frustrating.

    We are 95% sure it's the proxy server messing with the data we're sending as we often find the http version being changed.

  14. #14
    Registered User
    Join Date
    Apr 2004
    Posts
    22

    Same problem with me

    Though I am succesfully able to connect to internet using the Access points defined in My NOKIA 6600, none of my midlet is able to do so.

    WTK sample HTTP demo also failed to work properly from 6600 handset which otherwise works fine in the emulators.

    following is the code we are writing. Please help.


    class Submit extends Thread //implements Runnable

    {

    int score ;

    Display dsp ;

    String PhoneNumber ;

    public Submit ( int zScore, Display zDsp, String zPhoneNumber )

    {

    this.score = zScore ;

    this.dsp = zDsp ;

    this.PhoneNumber = zPhoneNumber ;

    }



    public void run()

    {

    HttpConnection con = null ;

    InputStream in = null ;

    StringBuffer buff = new StringBuffer ( ) ;



    try

    {

    /* **********************************************************/

    String SubmitQuery = new String ( "http://127.0.0.1/test.asp?i1="+this.score+"&i2="+this.PhoneNumber ) ;

    /* **********************************************************/

    System.out.println ( "Trying to open connection throgh HttpConnection quey is\n" + SubmitQuery ) ;

    con = ( HttpConnection ) Connector.open ( SubmitQuery ) ;

    System.out.println ( "Connected through HttpConnection" ) ;

    con.setRequestMethod ( HttpConnection.GET ) ;

    in = con.openInputStream ( ) ;

    int ch ;

    while ( (ch = in.read ( ) ) != -1 )

    {

    if ( ch != '\n' )

    {

    buff.append ( (char) ch ) ;

    }

    else

    {

    String lin = new String ( buff.toString ( ) ) ;

    System.out.println ( lin ) ;

    buff = new StringBuffer ( ) ;

    }

    }

    String lin = new String ( buff.toString ( ) ) ;

    //System.out.println ( lin ) ;



    Alert al = new Alert ( "Score Updated", "Your score has been submitted", null, null ) ;

    //al.setTimeout ( Alert.FOREVER ) ;

    al.setTimeout ( 1000 ) ;

    al.setType ( AlertType.CONFIRMATION ) ;

    dsp.setCurrent ( al ) ;



    }

    catch ( IOException err )

    {

    Alert al = new Alert ( "Error", "Errors occured while submitting score\nScore could not be submitted", null, null ) ;

    al.setTimeout ( Alert.FOREVER ) ;

    al.setType ( AlertType.ERROR ) ;

    dsp.setCurrent ( al ) ;

    }

    }

    }

Posting Permissions

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