Results 1 to 2 of 2

Hi I am quite new to bb. Currently I am using the the model 8100 ... BlackBerry Internet & Email forum

  1. #1
    cooldili's Avatar
    cooldili no está en línea Stack level 1
    Join Date
    Apr 2008
    Posts
    1

    Question HttpConnection faliure - Please Help!!!

    Advertisement



    Hi
    I am quite new to bb. Currently I am using the the model 8100 pearl for testing the developed code.
    In my application I need to establish HttpConnection or StreamConnection successfully. I need to give the parameters of APN settings in the code itself, without manually entering the APN settings in the phone. Therefore I have cleared all the APN settings in the phone.

    I am using J2ME for development and I have written the following code segment.


    HttpConnection connection = null;
    InputStream stream = null;
    StringBuffer b = new StringBuffer();

    try {
    connection = (HttpConnection)Connector.open("http://www.google.com/"+";WAPGatewayIP=<IP>"+";WapGatewayAPN=<APN>") ;
    stream = connection.openInputStream();
    boolean firstItr = true;
    int test=0;
    int ch;
    while ((ch = stream.read()) != -1) {
    b.append((char) ch);

    if(firstItr){
    test = ch;
    firstItr = false;
    }
    }
    Form form = new Form("Test");
    form.append(b.toString());
    Alert aleart = new Alert(null,"Connection successful \n"+test, null, AlertType.INFO);

    aleart.setTimeout(1000);
    Display.getDisplay(this).setCurrent(aleart,form);
    stream.close();
    connection.close();
    System.out.println("connection closed");
    destroyApp(false);
    } catch (IOException e) {
    Alert aleart = new Alert(null,"Connection unsuccessful "+e.toString(), null, AlertType.ERROR);
    aleart.setTimeout(1000);
    Display.getDisplay(this).setCurrent(aleart);
    }



    That is the code i have written. Sometimes the connection establishment throws no exceptions but it doesnt give out any data. The method 'stream.read()' returns -1 always.

    At some instances the connection does not establish successfully and throws an IOEXception: open tunnel max timeout.

    Please help me to overcome this issue. Have done lot of search but still couldn't find a solution. I will be very greatful a is anyone can help me in this.

  2. #2
    tony_ctc's Avatar
    tony_ctc no está en línea Stack level 2
    Join Date
    Jan 2008
    PIN/ID
    2434cbed
    Posts
    33
    Well, it all depends what connection type you want to use...

    Here is the type of connections and how to connect:

    Direct TCP:
    HttpConnection http = (HttpConnection) Connector.open(url+";deviceside=true");

    MDS:
    HttpConnection http = (HttpConnection) Connector.open(url+";deviceside=false");

    The only thing I couldn't find yet is the BIS-B connection... But if you will connect via APN just use the Direct TCP connection...


    Hope it helps...

    ~via BB (wap.pinstack.com)~

Tags for this Thread

Posting Permissions

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