×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    18

    HttpConnection issue on Nokia 6300

    Hi,

    I am facing a challenge in J2ME code. When I execute following code on Nokia 6300 it produces service not supported.
    i have executed same code on Noka 6100, N73 and 6120 Classic.
    Can any guide me about the error. Please look in to the code
    I receive error on Sage "2" (if(mHttpConnection.getResponseCode() != HttpConnection.HTTP_OK))

    Code:
    //////////////////// Source Code/////////////////
      private void connect() {
        InputStream ins = null;
        
        String s = new String() ;
    
        try 
        {
          // Query the server and retrieve the response.
          mWaitCanvas.setMessage("Connecting...");
          mHttpConnection = (HttpConnection)Connector.open(mURL, Connector.READ_WRITE,true);
          mStage = "1";
          mHttpConnection.setRequestMethod(HttpConnection.GET);
          mHttpConnection.setRequestProperty("Connection", "close");
          //mHttpConnection.setRequestProperty("User-Agent", "");
          mStage = "2";
          if(mHttpConnection.getResponseCode() != HttpConnection.HTTP_OK)
          {
              throw (new HTTPException(mHttpConnection.getResponseCode(), mHttpConnection.getResponseMessage()));
              
              //throw (new HTTPException(mHttpConnection.getResponseCode(), mHttpConnection.getResponseMessage()));
          }
          
          mStage = "2.5";
          ins = mHttpConnection.openInputStream();
          mStage = "3";
          // Pull back the server's response. If a content length is not
          // specified, we'll just read 255 bytes.
          mWaitCanvas.setMessage("Receiving...");
          //////////////////////////////////
            
     
             // reading the response from web server character by character
             int ch;
             while( (ch = ins.read()) != -1 ) 
             {
                s = s + (char) ch;
             }      
          mStage = "4";
          ////////////////////////////////
    //      int contentLength = (int)mHttpConnection.getLength();
    //      if (contentLength == -1) contentLength = 255;
    //      byte[] raw = new byte[contentLength];
    //      int length = ins.read(raw);
    
          // Clean up.
          ins.close();
          mHttpConnection.close();
          mStage = "5";
          // Show the response to the user.
          //String s = new String(raw, 0, length);
          //mForm.networkResponse(s);
    
          
          httpResultListner.networkResponse(s);
          
        }
        catch (HTTPException ex)
        {
            try {
              if (ins != null) ins.close();
              if (mHttpConnection != null) mHttpConnection.close();
            }
            catch (IOException ignored) 
            {
            }
            //mForm.networkException(ioe);
           // httpResultListner.networkException();
        }
        catch (IOException ioe) {
          if (mCancel == false) {
            try {
              if (ins != null) ins.close();
              if (mHttpConnection != null) mHttpConnection.close();
            }
            catch (IOException ignored) 
            {
            }
            //mForm.networkException(ioe);
            httpResultListner.networkException(ioe);
          }
    
          mCancel = false;
        }
      }

  2. #2
    Regular Contributor
    Join Date
    Apr 2007
    Posts
    220

    Re: HttpConnection issue on Nokia 6300

    Hi,

    Few check points to ensure your midlet will work with GPRS-

    1- Do you have GPRS enabled in your MSISDN.
    2- Have you configured the proper ASSCESS POINT.
    3- Are you able to browse the web using native browser.

    Please let us know so that we can help you further.

    Regards
    Amit

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    18

    Re: HttpConnection issue on Nokia 6300

    Thanks for reply.

    1- I have active GPRS cnnection on mobile
    2- I deployed application OTA
    3- I am able to browse on my mobile.

    Regards,

    Imran Iqbal

  4. #4
    Regular Contributor
    Join Date
    Apr 2007
    Posts
    220

    Re: HttpConnection issue on Nokia 6300

    Hi Iqbal,

    On S40 3rd Ed. onwsrds devices MIDlets have issues of connecting to GPRS with WAP APN. In simple words the midlet can not connect using basic GPRS plans provided by the operators.

    You can verify this by downloading any third part appliucation such as opera mini or gmail.

    If you have the INTERNET APN then the MIDlet will work smoothly.

    Hope this will help you.

    Regards
    Amit

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    18

    Re: HttpConnection issue on Nokia 6300

    Hi,

    I have tested same application on Sony Ericsson K700i and gives same error. But woking fine on Blackberry.

    Regards,

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: HttpConnection issue on Nokia 6300

    In addition to what others have answered below, you say that you are able to browse on the phone, but does for example Opera Mini (or any other MIDlet connecting to network) work? As MIDlets are using a predefined access point, browser might work but MIDlets do not.
    http://blogs.forum.nokia.com/blog/ha...-configuration

    Hartti

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    18

    Smile Re: HttpConnection issue on Nokia 6300

    Issue Resolved

    Can I get the list of Acces Points or Can i get the Preffered/ Selected Access Point name in Midlet like Opera Mini shows the preffered Access pont's name before going to connect GPRS.

    6300 uses preffered acces point for third party applications.

    Thakns for yor guidance. I appreciate.

    Regards,

    Imran Iqbal

Posting Permissions

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