Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User mircearechi's Avatar
    Join Date
    Oct 2006
    Posts
    13
    Hi,

    i'm testing a game on a nokia 6021. I have a Http connection on wich i try to do a POST (i tried also with a GET but same result) and on connection (respCode = c.getResponseCode(); ) i receive an "Error on HTTP connection"

    The same code works fine on a Nokia N70 and on every emulator i tested (Series 40 emulator, Series 60 emulator, Sony Ericsson, Motorola). I would think this is a bug for this device ... or i just don't do the connection correct.

    The address i'm connecting to is : http://test.test.com:8080/Web/Servlet
    The servlet is on a Tomcat

    The logs shows that Tomcat does not receive any request from client.

    I don't understand what is wrong here... my code ... the jvm on 6021 ...if it's a bug in jvm , is there a workaround for this ?

    Thanks,
    Mircea

    The code is :

    Code:
               HttpConnection c = (HttpConnection)Connector.open(url);                        
                                        
                c.setRequestMethod(HttpConnection.POST);
                            
                byte[] ba = reqData.getBytes();                  
            c.setRequestProperty("content-type","application/x-www-form-urlencoded");            
                c.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.1");
                
               OutputStream os = c.openOutputStream();                    
                
               os.write(ba);
                            
                //os.flush();     
                os.close();     
                
                int respCode = c.getResponseCode();
                                       
                if(respCode == HttpConnection.HTTP_OK) {
                           //some code
                }
    Last edited by mircearechi; 2006-11-08 at 13:09.

  2. #2
    Registered User mircearechi's Avatar
    Join Date
    Oct 2006
    Posts
    13
    I also tested this code on a Motorola V360 and it works ... it must be a nokia bug ... and i hope there is a workaround for this


    Mircea

  3. #3
    Super Contributor peterblazejewicz's Avatar
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699
    hi,

    is that device using the same sim card you've tested on different device? or its using different operator/service plan then other devices?
    if you have any other java-based applicatin that uses network connection than validate if they works at all on that device,

    if anything is missing in your code then only propably you could add content length header to post data if any,

    regards,
    Peter

  4. #4
    Registered User mircearechi's Avatar
    Join Date
    Oct 2006
    Posts
    13
    Hi peter,

    thanks for the reply.

    Yes i'm using the same sim card on all devices. And adding the content length parameter did not help

    Regards,
    Mircea

  5. #5
    Regular Contributor ionutianasi's Avatar
    Join Date
    Jul 2003
    Posts
    63
    some ideas:
    -use Connector.open(String name, int mode, boolean timeouts) style
    -as peter said, try other apps that use network connections on the same phone
    -check phone settings (access point & such )

  6. #6
    Registered User mircearechi's Avatar
    Join Date
    Oct 2006
    Posts
    13
    Finnaly i fixed it.

    It was the settings of the phone ( (
    This nokia 6021 is incredible complicated to configure ... as i said before the browser worke fine ..but the applications could not connect to internet. For this i had to make some changes in the Settings sub-menu (on Configurations settings a new configuration must be added with the same name as the configuration in the browser's settings, the acces point must be entered and then ACTIVATED)

    So now it works ... i can connect to any page ..but when i try to do a POST the data is not send...so i still have some work to do ...when i find the result for this one too i'll post it here

    Thanks,
    Mircea

  7. #7
    Registered User mircearechi's Avatar
    Join Date
    Oct 2006
    Posts
    13
    Finnaly REALLY fixed it.

    I also fixed the post problem. The problem was that the phone was sending the date but the the servlet did not parse them into parameters because the phone overwrites the headers and, instead of havin the application/x-www-form-urlencoded value for content-type the phone added a text/plain value so the servlet ignored the data from the stream.

    So i tested if the parameter's list is empty i read the stream and parse it by hand. And it works ... finnaly.

    If by any mean you choose a phone for testing j2me games or app hoos other then 6021.

    Thanks for all the help,
    Mircea

Similar Threads

  1. Replies: 2
    Last Post: 2006-10-06, 17:24
  2. Unable To Disconnect Http Connection
    By jaceline in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2006-09-21, 08:23
  3. Http Connection
    By jaceline in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2006-06-09, 16:53
  4. Close HTTp Connection in N6230i
    By cars2004 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-06-24, 10:46
  5. HTTP connection on 6310i, 7650, 9210 and in sony-ericsson p800
    By mika1982 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2003-07-24, 16:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved