Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 11
Registered: ‎08-19-2008
My Device: Not Specified

Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

Blackberry 8310 Curve

Operator - Airtel

JDE 4.5.0

 

when i try to connect to my company website using the below code the line

connection = (HttpConnection)Connector.open("http:\\www.bigadda.com"); throws IOException: Timed out.

 

In a day, when i try to execute the code below code it runs 60% of the times but for the rest 40% it throws IOException

And when using the same phone, operator and opera browser it runs fine 100% of the times even when my code isn't working. I don't know what code the opera browser is using.

I even tried specifying the parameter as Connector.READ,Connector.WRITE, Connector.READ_WRITE but only Connector.READ_WRITE works other throws IOException.

 

The below code use to work 100% fine since last week.

new Thread(){ public void run(){ StringBuffer buffer = new StringBuffer(); try { HttpConnection connection = null; InputStream in = null; connection = (HttpConnection)Connector.open("http://www.bigadda.com"); }catch(Exception e){ System.out.println("Exception"+e); } }}.start();

 

Kindly Suggest me a way to resolve the issue.

New Developer
Posts: 11
Registered: ‎08-19-2008
My Device: Not Specified

Re: Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

I tried the same code on 8830

with operator as Reliance CDMA

My code works perfectly fine.

Even on Emulator it works fine.

BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

What route is your connection being made over?

 

What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 11
Registered: ‎08-19-2008
My Device: Not Specified

Re:Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

I have already read the article.

 

Sorry I forgot to mention that for Blackberry 8310 Curve , Operator Airtel i have just enabled the GPRS connection so i don't append any parameter like deviceside=false.

 

Do i need to append any parameter for GPRS?

 

 

Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Re:Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

According to your code it seems that you are trying to connect it by BES/MDS..i think you need to check your MDS that whether any connection request is coming or not,if it(MDS) is provided by service provider then may be your MDS is not working(need to contact to your service provider)........n it is connecting by browser because it is using direct TCP connection....Are you using your connection in a separate thread? 

New Developer
Posts: 11
Registered: ‎08-19-2008
My Device: Not Specified

Re: Re:Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

Hi Ankit,

Thanks for the reply.

The Blackberry Browser doesn't work. As there is no MDS.

I'm using Opera for as my internet browser which works fine. 

The SIM is only GPRS enabled.

And sometimes the code is working and abruptly it stops working.

 

Yea  as you can see in the code the connection stuff is happening in a separate thread.

Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Re:Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

If there is no MDS,then you try to connect it by direct TCP,by setting the parameter "deviceside=true"  in the URL,but for that you have to create new  application,because you cannot allow your same application first try to connect by MDS and then  by TCP.......I recommend you to go through following links,this may help your case.....

1.http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=3200

2.http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To_...

3.

 
New Developer
Posts: 11
Registered: ‎08-19-2008
My Device: Not Specified

Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

[ Edited ]

Hi Ankit,

 

Thanks for the reply.

But i need some clarification relating to my code and the explaination that u have given

I am appending no parameters at the end of the url while passing the url to the open().

And on my airtel sim i have just activated gprs service.

Can you please answer me the following Qs

 

1) What will the type of connect used when i append no parameters?

2) Which type of connection will be used if i specify deviceside=true after the url in the open()?

3) What do i need to specify as parameter if i want to use BIS as my type of connection?

4) What do i need to specify as parameter if i want to use BES as my type of connection? 

 

Following is the class that i would like to use to analyse the type of connection that is available and use that for the current session

Can u please go thru the class and let me know if the check for BES,BIS, WAP and WIFI is correct.

and the following parameters for the respective type of connections would work fine

BIS -  ";deviceside=true;ConnectionUID=" + BIS_CONNECTION_UID;

BES -  ";deviceside=false";

WAP -  ";deviceside=true";

WIFI -  ";deviceside=true;interface=wifi";

 

 

class ConnectionAnalyser {

public boolean BIS_AVAILABLE;

public boolean BES_AVAILABLE;

public boolean WAP_AVAILABLE;

public boolean WIFI_AVAILABLE;

public String BIS_CONNECTION_UID = "";

public String CONNECTION_STRING;

 

public ConnectionAnalyser() {

setConnectionUID();

}

 

public void runAutoConfig(){

checkAvailableConnections();

setDefaultConnectionbyPriority();

}

 

public void checkAvailableConnections() {

try {

checkBISConnection();

checkBESConnection();

checkGPRSConnection();

checkWiFiConnection();

System.out.println(" \n call close wait screen \n");

} catch (Exception e) {

System.out.println("checkAvailableConnections :: " + e);

}

}

public void setDefaultConnectionbyPriority(){

CONNECTION_STRING = Defines.EMPTY_STRING;

for(int i=0;i<Defines.TOTAL_CONNECTION_TYPES;i++){

switch(i){

case Defines.BES:

if(BES_AVAILABLE){

CONNECTION_STRING = ";deviceside=false";

}

break;

case Defines.BIS:

if(BIS_AVAILABLE){

CONNECTION_STRING = ";deviceside=true;ConnectionUID=" + BIS_CONNECTION_UID;

}

break;

case Defines.WAP:

if(WAP_AVAILABLE){

CONNECTION_STRING = ";deviceside=true";

}

break;

case Defines.WIFI:

if(WIFI_AVAILABLE){

CONNECTION_STRING = ";deviceside=true;interface=wifi";

}

break;

}

if(!Globals.isStringNull(CONNECTION_STRING)){

break;

}

}

}

private boolean checkWiFiConnection() {

//Check if WIFI is active

WIFI_AVAILABLE = false;

//If RadioInfo is 0, there is no wifi available, if not test the transport

if (RadioInfo.getState() != 0) {

ServiceRecord[] serviceRecords = ServiceBook.getSB().findRecordsByUid("S TCP-WiFi");

for (int i = 0; i < serviceRecords.length; i++) {

ServiceRecord serviceRecord = serviceRecords[i];

if (!serviceRecord.isValid() || serviceRecord.isDisabled()) {

serviceRecord = null;

continue;

} else {

if (serviceRecord.getUid().equals("S TCP-WiFi")) {

WIFI_AVAILABLE = true;

//Device supports Wifi, but is it active? check

System.out.println("testing wifi connection ");

WIFI_AVAILABLE = testWifiConnection();

return WIFI_AVAILABLE;

}

}

}

serviceRecords = null;

}

return false;

}

private boolean testWifiConnection() {

try {

String url = "http://www.google.com;deviceside=true;interface=wifi";

System.out.println("Connecting to WiFi " + url);

Connector.open(url, Connector.READ_WRITE, true);

url = null;

return true;

} catch (Exception e) {

System.out.print("Exception in WiFi connection " + e);

return false;

}

}

private boolean checkBISConnection() {

BIS_AVAILABLE = CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_BIS_B);

//If BIS is available, get the UID

if (BIS_AVAILABLE) {

ServiceRecord serviceRecords[] = ServiceBook.getSB().findRecordsByCid("IPPP");

for (int i = 0; i < serviceRecords.length; i++) {

ServiceRecord serviceRecord = serviceRecords[i];

if (!serviceRecord.isValid() || serviceRecord.isDisabled()) {

serviceRecord = null;

continue;

} else {

if (serviceRecord.getCid().equals("IPPP")) {

BIS_CONNECTION_UID = serviceRecord.getUid();

break;

}

}

}

serviceRecords = null;

}

if (BIS_CONNECTION_UID.equals("")) {

return false;

} else {

return true;

}

}

private boolean checkBESConnection() {

BES_AVAILABLE = false;

BES_AVAILABLE = CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS);

return BES_AVAILABLE;

}

private boolean checkGPRSConnection() {

WAP_AVAILABLE = false;

if (RadioInfo.isDataServiceOperational() && CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_CARRIER)) {

WAP_AVAILABLE = true;

}

return WAP_AVAILABLE;

}

private void setConnectionUID() {

ServiceRecord serviceRecord[] = ServiceBook.getSB().getRecords();

for (int i = serviceRecord.length; --i >= 0;) {

if (serviceRecord[i].getCid().equals("IPPP")) {

BIS_CONNECTION_UID = serviceRecord[i].getUid();

break;

}

}

}

}

 

 


 

 Thanks in Advance

 

Message Edited by dolphinv on 09-05-2008 08:44 AM
Message Edited by dolphinv on 09-05-2008 08:52 AM
BlackBerry Development Advisor
Posts: 15,813
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

You can find the answeres to your questions here:

 

What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Connector.open("http:\\www.bigadda.com") throws IOException: Timed out

Hi,

I also would recomment you to go for document specifed by mark and especially would recommend the video

 

 

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=419

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=1765