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
Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)
Accepted Solution

Connection Closed Exception Blackberry Bold

Hello,

I'm having a very odd exception (ConnectionClosedException)and related to TCP socket and i was hoping someone could help me with it:

I'm trying to open a socket from my BB (Bold) to my server and i keep getting an exception after ~1min

The device is in Germany and connected to T-Mobile

The code i'm using is:

try {

   String URL = "socket://" + _serverIp + ":" + _port;

   connection = (StreamConnection)Connector.open(URL);

} catch (Exception e) {

//Print the exception

}

 

I tried to add to the URL the suffix: ";deviceside=true" and i got this exception and when i used ";deviceside=false"

i got "java.io.IOException: Invalid url parameter"

I did manage to connect to my server from different BB (Bold) on the same network and i tried to update the APN settings but it didn't help at all. 

Did someone encounter this problem?

Thanks a lot.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Connection Closed Exception Blackberry Bold

You have of course reviewed the following:

 

Network Transports video:

http://na.blackberry.com/eng/developers/resources/videolibrary.jsp#tab_ddetail_subtab_jde

 

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

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

";deviceside=false" is unlikely to work for you if you are not using a corporate BlackBerry - we shall assume you are not.

 

Using ";deviceside=true" means you will to code APN values, and according to this:

 http://www.pinstack.com/carrier_settings_apn_gateway.html

you should have

APN: internet.t-d1.de

User: td1

Password: gprs

 

Can you confirm that you are in fact using these settings in your TCP Options?

 

Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Connection Closed Exception Blackberry Bold

Hi,

 

Yes,I did read all the links you mentioned and i searched the forum before posting this question

but since none of the solutions mentioned worked i decided to post a question.

Regarding the APN settings, i used a different APN settings:

APN: internet.t-mobile

user: tm

pw: tm

 

Perhaps that's the problem, i'll try them too. I also tried to use WAP connection but i'm not sure how to use it in the connection API,

I did the following:

                    ServiceBook sb = ServiceBook.getSB();
                    ServiceRecord[] records = sb.findRecordsByCid("WPTCP");
                    String uid = null;
                   
                    for (int i = 0; i < records.length; i++)
                    {
                        if( records[i].isValid() && !records[i].isDisabled() && records[i].getUid() != null &&
                            records[i].getUid().length() != 0)
                            if (records[i].getUid().toLowerCase().indexOf("wifi") == -1)
                            {
                                uid = records[i].getUid();
                                break;
                            }
                    }
                   
                    if (uid != null)
                        URL += ";ConnectionUID=" + uid; //open a WAP 2 connection

 

However i can't find on the BB Bold any WAP service which isn't WiFi, am i doing something wrong or should i use the WiFi WAP?

Thanks.

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

Re: Connection Closed Exception Blackberry Bold

One of your exceptions is explained here:

 

Support - IOException - Invalid URL Parameter when using deviceside=false
Article Number: DB-00655
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/Support...

 

Regarding your 2 tests, were they both using the same SIM card?  If not, I recommend you verify with the carrier that they both have access to make a direct TCP connection through the APN you are using.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Connection Closed Exception Blackberry Bold

Hello,

Regarding the exception the link was useful, thanks (i verified the device isn't connected to a BES).

I did try another test however with the 2 SIM cards, i installed the RIM Network tool on this device and i tested it

each time with a different SIM and here are the results:

O2 2G SIM worked with:
- Direct TCP
- WiFi

T-Mobile 3G SIM worked with:
- Direct TCP
- WAP2
- WiFi

 

According to this i should be able to open a direct TCP connection over these carriers and the only difference is that

the RIM Network tool opens the connection to http://www.google.ca;deviceside=true

using the API: (HttpConnection) Connector.open(url);

and i'm trying to open connection to: socket://my_serverIp:server_port;deviceside=true

using the API: (StreamConnection)Connector.open(url);

 

Does it make any sense to you?

 

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

Re: Connection Closed Exception Blackberry Bold

[ Edited ]

What you describe sounds correct.  Are you able to make a socket connection to another server (such as www.rim.com:80)?

Message Edited by MSohm on 02-13-2009 10:47 AM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Connection Closed Exception Blackberry Bold

Hi,

 

I can't use the device probably in the next week as it's not mine, but i'll try to test it

in the mean while, can you please explain me the problem and why it sounds correct as you mentioned

in the your reply?

Thanks a lot.

 

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

Re: Connection Closed Exception Blackberry Bold

If the only difference between your application and the sample is the server and port that you are connecting to, it may not be a network issue but a problem actually reaching that server or port.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 216
Registered: ‎09-11-2008
My Device: 9000(Bold)

Re: Connection Closed Exception Blackberry Bold

Hello,

Did you mean in your former answer that the specific device has a problem reaching the server or in general? Also, do you know of a bypass i could use to solve this issue?

I have to add that i managed to install the same original application which i sent the user on a different BB device but on the same carrier and the same BB model and the application worked as expected (reached the server). I compared all the data i could think of between these 2 devices (TCP, APN) and found no difference.

Thanks.

 

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

Re: Connection Closed Exception Blackberry Bold

I recommend verifying that the user has access to make the type of connection your application is using.  Carrier's can restrict access to APNs and connection routes based on the user's plan.  They can contact their carrier to confirm.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker