×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    6

    Angry Another HTTP connection problem

    Hi
    Appologies... have trawled the forums looking for an answer to this but please can someone tell me what I'm doing wrong / do not have set...

    Trying to open http connection from midlet on 6320i, all runs fine as expected in emulators but on the phone just hangs; prompted to allow network access, respond Yes, the GPRS symbol appears, then gets the square around it but then sits there until it times out and gives the error in HTTP connection. I'm assuming it's tied up with access points but can't fathom it. Have a socket based midlet running on the same phone which connects through to a known endpoint with no problems. Can also browse http sites over GPRS no problem

    Thanx

    Please see code below

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    import java.io.*;
    import javax.microedition.io.*;

    public class http extends MIDlet
    {
    protected Display display;
    protected Displayable displayable;
    Form f = new Form("Dummy Form");

    public http()
    {
    display = Display.getDisplay(this);
    displayable = f;
    }
    public void startApp()
    {
    display.setCurrent(displayable);
    try
    {
    getViaHttpConnection("http://www.google.co.uk");
    }
    catch (Exception e)
    {
    e.printStackTrace(); throw new RuntimeException ("" + e);
    }
    }
    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {
    display = null;
    displayable = null;
    }


    void getViaHttpConnection(String url) throws IOException
    {
    HttpConnection c = null;
    InputStream is = null;
    int rc;
    String s = "";
    try
    {
    c = (HttpConnection)Connector.open(url);
    f.append("Line 1 connection object=" + c);
    rc = c.getResponseCode();
    f.append("Line 2");//never gets here when run on phone
    if (rc != HttpConnection.HTTP_OK)
    {
    throw new IOException("HTTP response code: " + rc);
    }
    is = c.openInputStream();
    String type = c.getType();
    int len = (int)c.getLength();
    if (len > 0)
    {
    int actual = 0;
    int bytesread = 0 ;
    byte[] data = new byte[len];
    while ((bytesread != len) && (actual != -1))
    {
    actual = is.read(data, bytesread, len - bytesread);
    bytesread += actual;
    }
    }
    else
    {
    int ch;
    while ((ch = is.read()) != -1)
    {
    s += (char)ch;
    }
    }
    }
    catch (ClassCastException e)
    {
    throw new IllegalArgumentException("Not an HTTP URL");
    }
    finally
    {
    if (is != null)
    is.close();
    if (c != null)
    c.close();
    }
    System.out.println(s);
    f.append(s);
    }
    }

  2. #2
    Regular Contributor
    Join Date
    Nov 2005
    Location
    Amman/Jordan
    Posts
    322

    Re: Another HTTP connection problem

    which APN u r using ..?
    make sure u r connecting to thr right apn ....

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    6

    Re: Another HTTP connection problem

    Hi dakoz
    please could you tell me how to check this?
    Thanx

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    6

    Re: Another HTTP connection problem

    Have set up an access point in personal config settings and set it as the preferred access point. Still the connection hangs.
    Am I missing something here? I assume that the Access point set under Settings->Configuration->Preferred Access Point is the one the midlet will use?
    Access Point itself added/configured under personal configuration settings with settings GPRS access point 'internet' as per http://www.filesaveas.com/gprs.html.
    Any ideas as to what else I may try?
    Thanx

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    5

    Re: Another HTTP connection problem

    check your APN Settings . Configure the proper APN .

    As i can see on your code there's nothing wrong , the only thing to be checked is the APN .

    Good Luck ....
    Last edited by irshad_ahmed; 2006-10-03 at 18:02.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    32

    Re: Another HTTP connection problem

    sup

    Your problem has nothing to do with ur APN. It is a bug in a wide range of Nokia phones, they all hang on HttpConnection.openInputStream(), just use HttpConnection.openDataInputStream() instead!

Similar Threads

  1. HTTP Connection problem with real series 40 device
    By pagadi in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-06-17, 09:28
  2. HTTP Connection problem on Nokia 3650
    By niko86 in forum Mobile Java Networking & Messaging & Security
    Replies: 7
    Last Post: 2004-04-16, 15:53
  3. problem using http: connection is paused or loss without reason
    By pablito816@hotmail.com in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-11-11, 23:06
  4. NOKIA vs. SIEMENS HTTP connection problem?
    By imarenic in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-11-03, 09:03
  5. HTTP connection problem on 7650
    By gpeschiera in forum Mobile Java General
    Replies: 1
    Last Post: 2002-10-30, 03:08

Posting Permissions

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