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
Regular Contributor
Posts: 59
Registered: ‎05-10-2012
My Device: 8800
My Carrier: verizon

wifi connection stops working on Curve 8530

Hello all

 

I have an app developed wiith BlackBerry JRE 5.0.0

 

I'm running it on a Bold and a Curve (8530)

 

The app is supposed to detect a phone call and, while the call is active, communicate via a socket using ssl with a server and receive information.

 

I'm assuming the socket uses the wifi connection.

 

Everything works as expected on the Bold.

Here are the specs for the Curve:

 

Curve 8530

OS v5.0.0.973

carrier Verizon

CDMA,Wi-Fi

 

The Curve exhibits behavior I cannot explain and I'm hoping to get some guidance here.

When the call connects, communication via the socket halts.  The connection is not broken, it just pauses until the call hangs up.  Then all info from the server is received at once - I want each message to be received as it is sent.

At first I thought this was due to CDMA being unable to do simultaneous voice/data transfers.  But I'm seeing some things I can't explain.  Namely, sometimes when I make a call I am able to use the browser to access sites like wikipedia.org

 

Admittedly, sometimes the connections time out and sometimes I get a dialog saying something like "You cannot access the network while a voice call is active" and its this lack of consistent behavior that's making me wonder if I'm missing something.

I am creating the socket as follows:

 

conn = (StreamConnection)Connector.open("ssl://"+server+":10036;deviceside=true");

_out = conn.openOutputStream();

_dis = conn.openDataInputStream();

 

and use _out and _dis to write/read to/from the socket.

I hand _dis off to a Thread that handles the reading.  Here's the important part of the Thread's run():

 

while (mInputStream != null) {

  log(this.getName()+" before readUnsignedByte");

  int ch = mInputStream.readUnsignedByte();

  log(this.getName()+" after readUnsignedByte");

mInputStream is _dis

 

I know the pause occurs at  int ch = mInputStream.readUnsignedByte(); because when I stop receiving messages from the server, the last thing that shows up in the log is log(this.getName()+" before readUnsignedByte");

 

When the call is disconnected I know int ch = mInputStream.readUnsignedByte(); is executing because the NEXT message that shows up in the log is  log(this.getName()+" after readUnsignedByte");

 

Also, I added

 

if (WLANInfo.getWLANState() != WLANInfo.WLAN_STATE_CONNECTED){

  display a dialog saying "WIFI GONE"

}

 

to the code to verify the wifi is inaccessible.  Sometimes I get dialog, sometimes I don't.  Regardless, control is blocked at the readUnsignedByte() I pasted above.

 

I was all ready to attribute this to CDMA when I made a phone call on the device and used the browser to open my gmail - but even that is not consistent.  Its the lack of consistency that's making me wonder if I'm missing something.  

 

Is this normal behavior on the Curve?  Is there something missing from the way I create the socket?  Is there some setting on the Curve that needs to be adjusted for ssl?  Is there a BlackBerry class I should be using instead of javax.microedition.io.Connection and StreamConnector?

Regular Contributor
Posts: 59
Registered: ‎05-10-2012
My Device: 8800
My Carrier: verizon

Re: wifi connection stops working on Curve 8530

Well, after a whole lot of work I came up with a solution.  I think I understand why its working, but am seeking confirmation because I'm making alot of assumptions.

 

For some reason, yesterday I deceided to look at the Certificates on both devices.

 

It turns out, the Curve (which was not working properly) had about 6 certficitates the Bold (which was working properly) did not have.

 

FWIW - these certificates all had the word "Swiss" as the first word in their names.

 

Once I deleted them, the Curve stated running my app almost as well as the Bold does.  The Curve is still has some problems detecting my network and it may lose the wifi connection after I exit my app - but even so this is 100% better than the way it was running before.

What I don't understand is why would the presence of a certificate cause a device to operate so poorly?  Remember my previous post where I said it would take a minimum of 2-3 "scanning for networks" to detect my home network and 2-3 connect attempts to successfully access it on top of the problems running the app.

A certificate is simply some SSL credentials, isn't it?  My results imply the SSL credentials for Swiss-whoever-they-are were preventing wifi on my Curve from operating properly.  Why?  Are the any rules/best practices for removing certificates?  I've always thought certificates were installed on the device on an as needed basis - if you accessed a website that required SSL access and chose to allow it then the certificate would be autamotically installed.  Is that correct?

This actually has me quite concerned.  I cannot control the certificates installed on the devices that run my software.  I need to provide some way to indicate to the user that there may be a way to indicate there's a certificate problem but is there even a part of the BlackBerry API exposing this?

 

Any help, advice, commiseration would be greatly appreciated.

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

Re: wifi connection stops working on Curve 8530

Two things immediately come to mind.

 

But my immediate reaction is the that the certificate thing is just a red herring.  Like you, I see no reason they will make a difference.

 

The first thing that you should look at is this:

"deviceside=true"

By specifying this you are saying that the connection will be made via the wireless network.  This connection will never go over WiFi. Compare this with the Browser which will almost certainly be able to use WiFi.  I would suggest that you see if you can connect via WiFi and if you can, use it.

 

Have a look here for the appropriate connection suffix to use:

http://supportforums.blackberry.com/t5/Java-Development/Different-ways-to-make-an-HTTP-or-socket-con...

Search the forum for some code to see if WiFi is available.

 

You might consider using ConnectionFactory API. 

 

The second thing to note is a capability of the device.  I can't talk for CDMA, but for GSM phones, there are various levels of connection that they can use.  If they support 3G, then simultaneous voice and data is possible, provided you have a 3G signal.  If you don't have a 3G signal, then phone calls might break off the data.  In GSM land, the Bold has a much better wireless chip and so is much more likely to support 3G.  In GSM land, if you look at the letter on the top right of the Home screen, it will tell you what sort of wireless connection you have, and so you can figure out from that if you can currently support voice and data.  Perhaps there is something similar in CDMA land. 

 

Hope this helps.

Regular Contributor
Posts: 59
Registered: ‎05-10-2012
My Device: 8800
My Carrier: verizon

Re: wifi connection stops working on Curve 8530

This is getting more strange as I look into it.

 

There are a few things I don't understand when you wrote:

 

"The first thing that you should look at is this:

"deviceside=true"

By specifying this you are saying that the connection will be made via the wireless network.  This connection will never go over WiFi. Compare this with the Browser which will almost certainly be able to use WiFi.  I would suggest that you see if you can connect via WiFi and if you can, use it."

 

Why do you say this connection will never go over WiFi?  

 

I do want my socket to connect over WiFi and I want it to use TCP/IP directly.  When I was developing this I read:

 

http://docs.blackberry.com/en/developers/deliverables/7693/Use_a_socket_connection_508960_11.jsp

 

It says:

 

"To open a socket connection over direct TCP, append the deviceside=true parameter to the end of the URL.

 

private static String URL = "socket://local_machine_IP:4444;deviceside=true";
StreamConnection conn = null;
conn = (StreamConnection)Connector.open(URL);"

 

Is this now unnecessary for some reason?  

 

From the document you posted, I think you say to use "interface=wifi" because this will force the connection to bypass the BlackBerry Infrastructure, BlackBerry Enterprise Server and BlackBerry Internet Service and make its connection directly thru the network accessible via wifi.  Is that correct?

 

Examining my device I find it does have 3G in the upper right hand corner of the home screen.   If I recall correctly, the 3G indicator stays lit pretty consistently.  What is not consistent is the behavior of the WiFi icon underneath it.  I've already posted that my Curve frequently loses access to my network - or at least I'm assuming that is what's going on when the network name disappears from the home screen.  What I've just noticed is after I reconnect to the network via Manage Connections | Set Up Wi-Fi Connection | Scan For Networks , it takes a few minutes for the Wi-Fi icon to turn white indicating WiFi is active.  Is this just a delay in updating the screen icon after the connection has been made?

Another odd thing just occurred.  I deleted all the certificates from my Curve.  Its a used device, I was given for testing and figured there would be no harm.  Upn reboot, I was asked to download and trust a certificate named "rcp4.us.blackberry.com, Thawte SSL CA".   What is this certificate?

It displays with a ? next to the name.  When I select it it says "Stale Chain Status" and "Unknown Chain Status" - is this why the ? displays?

 

Is there a way to get the device to tell me the strength of the connection when its connected to my home network via the wireless connection?

 

 

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

Re: wifi connection stops working on Curve 8530

OK, loads of questions here.  Let us deal with the connection one first.

 

All the possible connection methods available use TCP/IP.  So regardless of which method, it is TCP.

 

One of the connections method is called Direct TCP, aka Carrier TCP.  This connects via the carrier's TCP/IP gateway.  Compare this with WiFi which connects via your own gateway. Or deviceside=false, which connects via the MDS.  The best explanation of the connection methods and the various gateways in use is here:

http://supportforums.blackberry.com/t5/Java-Development/Networking-Transports-II/ta-p/446742

 

You will see from this video that if you specify deviceside=true you will connect via your carrier's gateway, which it will get to using the wireless (carrier) network.  So this method will never use WiFi. 

 

Use, coding ";interface=wifi" will use the WiFi network to go directly to the target URL. 

 

While your device has 3G, then you should be able to use ";deviceside=true" and make a phone call at the same time.  But if this drops off 3G, you will not be able to do this. 

 

Now your WiFi indicator question is a little complicated.  WiFi has three states:

a) Not available - no icon

b) When it is available - this is when you see the logo 'silver'

c) When the Blackberry has determined that it can get to the RIM infrastructure over WiFi and will use it (WiFi) in preference to wireless for BlackBerry specific processing (not ";deviceside=true" connections) - this is when the logo goes 'white'. 

 

I am sorry I have no idea regarding certificates, but as noted, do not think they are relevant to this problem. 

 

Regarding the strength, have a look at RadioInfo.getSignalStrength().