BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 01-25-2008, 12:34 AM   #1 (permalink)
New Member
Join Date: Jan 2008
Model: no
Carrier: se
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Socket connection

Please Login to Remove!

For last few days I am trying to write a very simple application that needs to open a socket connection. But unfortunately I'm unable to run my app in the device. I'm using the following line of codes to do that, (I am attaching only the relavant part of the code):
SocketConnection m_cObjSocketCon = null;
try {
lURL = "socket://"+pServerName+":"+pPort;
m_cObjSocketCon = (SocketConnection),Connector.RE AD_WRITE,false);
}catch (Exception ex) {
System.out.println("Exception[1] "+ex.toString());
if(null == m_cObjSocketCon){
lURL += ";deviceside=true";
m_cObjSocketCon = (SocketConnection),Connector.RE AD_WRITE,false);
}catch (Exception ex) {
System.out.println("Exception[1.1] "+ex.toString());
I'm deplyoing the code in a 8310 device. I've subscription of type that allows me to connect to any IP. I'm able to connect to different IPs from the "Internet Browser". But for the same IPs I'm always getting an exception " Unable to open connection." in both the cases (Exception[1] & Exception[1.1]).
I've APN configured in the device.
I've given sufficient Security permissions to the application.
Can anybody please tell me if anything I'm missig?
BTW: MDS is not activated in my device (I do not know how to activate also). Can it be a reason for my app not to be able to connect to the IP?
The same app is working very fine in simulator.

Last edited by Preetimandap : 01-25-2008 at 06:24 AM.
Old 01-26-2008, 02:15 PM   #2 (permalink)
New Member
Join Date: Jan 2008
Model: 8320
Carrier: Verizon
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts

It's not uncommon at all for connection oriented programs to work perfectly fine in the simulator and then not work at all on the device itself.

I had the same issue with a 'socket:' protocol program and while I never saw the 'Unable to open connection' exception you are seeing I wasn't able to get it to
work until I discovered the following...

The 'RIM' socketdemo example in the SDK is always adding the secret
";deviceside=true" string to the ends of the URLS.

Once I moved the program over to a real device and started targeting either either the Direct TCP option with ";deviceside=true" OR trying it against the MDS with ";deviceside=false" I discovered something.

Pages would ONLY be retrieved but ONLY if I never add the ";deviceside=false" parameter.

";deviceside=true" OR NO ";deviceside" string at all ( removed from
end of URL ) worked fine.

Specifically adding ";deviceside=false" to try and force a direct TCP
connection would send it off to la-la-land.

What is interesting, however, is that when I would REMOVE the
"deviceside" parameter altogether it would always DEFAULT to
using Direct TCP because the protocol is "socket:".

So I think the 'on device' rule is that if you want to force Direct TCP
connection for a "socket:" connection just be sure you do NOT
try and force it to happen with the ";deviceside=true" secret
parameter. Just leave that off the URL and it should DEFAULT
to using Direct TCP connection option.

All of the above applies to a BB 8830 running on the Verizon Network
with Service Books onboard for both BIS and Direct TCP.

There is only 1 browser on the BB 8830 from Verizon and it is
always configured to use the BlackBerry Internet Proxy Service
( BIS ) running in Canada for all Internet Access.

What parameters, if any, do you have on the end of your URL?

Does the RIM socketdemo from the JDE work on your actual device?

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