BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-22-2008, 02:21 AM   #1
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Default HTTP Connection Failure

Please Login to Remove!

Please anyone tell me why my App Can't Connect.
I am ne to develop this kind of app.
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;

import demo.screen.utils.TitleField;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ObjectListField;
import net.rim.device.api.ui.container.MainScreen;
//-----------------------------
import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
//import net.rim.device.api.io.Base64OutputStream;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.Menu;

/**
 *
 * @author Abhinav
 */
class MyMainScreen extends MainScreen {

    //private static int dialogResponse;
    private int status = -1;
    private final String site0 = "http://www.google.com";
    private final String site1 = "http://www.yahoo.com";
    private final String site2 = "http://www.ariosesoftware.com";
    private final String sideKick2=";wapgatewayip=100.1.200.99;wapgatewayport=8080;wapgatewayapn=airtelgprs.com;deviceside=true";
    private final String sideKick1=";deviceside=true;wapgatewayapn=airtelgprs.com";
    private ObjectListField lfMain;
private UiApplication myApp;
    public MyMainScreen() {
        super(DEFAULT_MENU | DEFAULT_CLOSE);
        TitleField tfTitle = new TitleField("My-Http-Connection");
        setTitle(tfTitle);
        lfMain = new ObjectListField(ListField.FIELD_LEFT);
        lfMain.insert(0, site0);
        lfMain.insert(1, site1);
        lfMain.insert(2, site2);
        add(lfMain);
        myApp=UiApplication.getUiApplication();
    }
    MenuItem miCon = new MenuItem("Connect", 110, 10) {

        public void run() {

            Runnable r = new Runnable() {

                public void run() {
                    connect();
                }
            };
            Thread th = new Thread(r);
            th.start();
        }
    };

    public void connect() {
        int index = 0;
        index = lfMain.getSelectedIndex();
        String selInd = (String) lfMain.get(lfMain, index);
        HttpConnection httpConn = null;
        boolean keepGoing = true;

        try {
            httpConn = (HttpConnection) Connector.open(selInd+sideKick2);

            while (keepGoing) {
                status = httpConn.getResponseCode();
                switch (status) {
                    case (HttpConnection.HTTP_NOT_FOUND):
                        myApp.invokeAndWait(new Runnable() {

                            public void run() {
                                Dialog.alert("Http Not Found");
                            }
                        });
                        keepGoing = false;
                        break;
                    case (HttpConnection.HTTP_MOVED_TEMP):
                        UiApplication.getUiApplication().invokeAndWait(new Runnable() {

                            public void run() {
                                Dialog.alert("Http Found");
                            }
                        });
                        keepGoing = false;
                        break;
                    case (HttpConnection.HTTP_OK):
//Connection is 200 OK.
//Download and process data.
                        myApp.invokeAndWait(new Runnable() {

                            public void run() {
                                Dialog.alert("Connected");
                            }
                        });
                        keepGoing = false;
                        break;
                    case (HttpConnection.HTTP_UNAUTHORIZED):
                        myApp.invokeAndWait(new Runnable() {

                            public void run() {
                                Dialog.alert("Unauthorized Access");
                            }
                        });
                        break;
                    default:
//The connection failed for some other reason.
//Handle failed connection.
                        keepGoing = false;
                        break;
                }
            }
//Close the connection.
            httpConn.close();
        } catch (final Exception e) {
//Handle the exception.
            myApp.invokeAndWait(new Runnable() {

                public void run() {
                    Dialog.alert("Exception: Can't Connect, " + e.getMessage());
                }
            });
        }
    }

    public void makeMenu(Menu m, int inst) {
        super.makeMenu(m, inst);
        m.add(miCon);
    }
}
Regards
Offline  
Old 07-22-2008, 02:34 AM   #2
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

Any error messages or exceptions like "Blocking operation not permitted on event dispatch thread"?
First of all put your connection code in a separate thread and start it from your main screen.
Offline  
Old 07-22-2008, 03:47 AM   #3
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Default

My Code starts in a new thread.
and this is my first screen.
The error you have mention came, but on the line :
status=http.getResponseCode();
but after putting in the thread, was removed.
Code:
MenuItem miCon = new MenuItem("Connect", 110, 10) {

        public void run() {

            Runnable r = new Runnable() {

                public void run() {
                    connect();
                }
            };
            Thread th = new Thread(r);
            th.start();
        }
    };
The error that now comes (using sideKick1=;wapgatewayip=206.51.26.197;wapgatewaypo rt=19631;wapgatewayapn=blackberry.net;deviceside=t rue;tunnelauthpassword='';tunnelauthusername='') is:
Malformed URl Exception
Offline  
Old 07-22-2008, 04:07 AM   #4
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

sorry, must have missed it...

Ther must be something wrong in your string. I think the spaces is not the error, but only formatting problem. try removing tunnelauthpassword='';tunnelauthusername=''

Also blackberry.net as apn for WAP gateway shouldn't work, so try to remove it, too
Offline  
Old 07-22-2008, 05:06 AM   #5
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Default

I have copied that from Service Record, and earlier I was not using sideKicks at all. Though using MDS it runs fine on emulator, but MDS is not activated on the device. Hence I feel that the Opera, Yahoo Messenger are not using it either.
I have also gone through the default , but it doesn't work either
WapGatewayIP

Code:
(local BB installation Dir)BlackBerry%20JDE%204.2.0/docs/api/javax/microedition/io/Connector.html#open(java.lang.String)
------------
What setting are you using anyways?
------------
I am not using BES but can the BIS be used. If it can be of help, then how can I activate it?
Regards

Last edited by abhsax1978@hotmail.com; 07-22-2008 at 05:38 AM..
Offline  
Old 07-22-2008, 06:08 AM   #6
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Default

Code:
sideKick2=";wapgatewayip=206.51.26.197;wapgatewayport=19631;19630;wapgatewayapn=blackberry.net;deviceside=true;tunnelauthusername=''";
using the above reports :
Code:
configuration doesn't match
Offline  
Old 07-22-2008, 06:36 AM   #7
Ivanov
Talking BlackBerry Encyclopedia
 
Join Date: Apr 2008
Location: Germany, BW
Model: -
PIN: N/A
Carrier: -
Posts: 310
Default

the information from the service records is more "informational". For example the two provided ports cannot be used it that way as parameter. Also blackberry.com APN makes only sense with a BES.

look here for different ways to make a connection:
Livelink - Redirection

so you can use the direct TCP connection if your carrier supports it or WAP gateway building the parameters by yourself according to the info in the link.

If you are a RIM Alliance Partner you could use BIS-B.
Media Library

Last edited by Ivanov; 07-22-2008 at 06:37 AM..
Offline  
Old 08-03-2008, 11:14 PM   #8
abhsax1978@hotmail.com
Thumbs Must Hurt
 
abhsax1978@hotmail.com's Avatar
 
Join Date: Jun 2008
Location: NOIDA
Model: 8100
OS: 4.2.1.91
PIN: 2052AEF9
Carrier: Soft. Engg.
Posts: 111
Smile

Abhinav from India to Ivanov from Germany

with the following:
sideKick2=";wapgatewayapn=airtelgprs.net;devicesid e=true;"

now it is running OK as the service we use is that of Airtel.

Last edited by abhsax1978@hotmail.com; 08-03-2008 at 11:15 PM..
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


CBB65A Round Electric Motor Start Run Capacitor 450VAC 50uf 50MFD Aluminum picture

CBB65A Round Electric Motor Start Run Capacitor 450VAC 50uf 50MFD Aluminum

$9.53



AmRad USA2236 CPT Round Motor Run Capacitor 45+5 MFD 370 or 440VAC 50-60Hz picture

AmRad USA2236 CPT Round Motor Run Capacitor 45+5 MFD 370 or 440VAC 50-60Hz

$29.99



ABB Capacitor Unit 3HAC14551-3/05A picture

ABB Capacitor Unit 3HAC14551-3/05A

$949.95



Nichicon Capacitor CE 85C NX 450V 8200uF  picture

Nichicon Capacitor CE 85C NX 450V 8200uF

$74.95



6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF picture

6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF

$155.59



CBB61 250V  Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF picture

CBB61 250V Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF

$129.95







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.