BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-26-2008, 12:21 PM   #1 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8100p
PIN: N/A
Carrier: none
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default HttpConnection faliure - Please Help!!!

Please Login to Remove!

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 open tunnel IOEXception.

Please help me to overcome this issue. I will be very greatful a is anyone can help me in this.
Offline  
Old 04-26-2008, 12:22 PM   #2 (permalink)
iPhone Convert
 
juwaack68's Avatar
 
Join Date: Oct 2005
Location: Tulip City - MI
Model: iP5
OS: 6.0.2
PIN: to beans
Carrier: I'm not
Posts: 13,875
Post Thanks: 3
Thanked 72 Times in 55 Posts
Default

Moved to Developer Forum.
__________________
No longer a BES Admin, but it was fun while it lasted!
Offline  
Old 04-26-2008, 10:37 PM   #3 (permalink)
New Member
 
Join Date: Apr 2008
Model: 8100p
PIN: N/A
Carrier: none
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi...
I have done lot of internet search but still couldnt find a solution. Anyone who has come across this error please help.
Offline  
Closed Thread


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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