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 Contributor
peroseth
Posts: 9
Registered: ‎02-23-2012
My Device: Developer

Connecting to network (HttpConnection) with BB OS 7 devices

Hi,

 

I have an app that is using HttConnection with the plain URL (no parameters added) and it is working just fine for all BB devices up to devices running BB OS 7.

 

Question 1: What has been changed in BB OS 7 since this does not work anymore?

 

To solve this I tried using the TransportDetective and URLFactory from the NetworkAPIAlternative project (http://supportforums.blackberry.com/t5/Java-Development/What-Is-Network-API-alternative-for-legacy-O...

 

And added the following code to add right parameters to the URL before creating the HttpConnection:

		TransportDetective td = new TransportDetective();
		URLFactory urlFactory = new URLFactory(gatewayURL);

		if(td.isCoverageAvailable(TransportDetective.TRANSPORT_MDS)){
			//Use MDS if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getSrMds());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_BIS_B)){
			//Use BIS-B if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getBisServiceRecord());
		}
		else if (td.isDefaultTcpCellularServiceRecordAvailable()){
			//Use default TCP Celluar Service if available (APN)
			gatewayURL = urlFactory.getHttpWap2Url(td.getDefaultTcpCellularServiceRecord());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_TCP_WIFI)){
			//Use TCP WIFI if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getTcpWiFiServiceRecord());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_WAP2)){
			//Use WAP 2 if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getWap2ServiceRecord());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_WAP)){
			//Use WAP 1 if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getWapServiceRecord());
		}

 

Still it does not work. If I set it to just use TRANSPORT_WAP2 it will work on BB OS 7, but only if the WiFI is enabled. The app should be able to use the network with all available transport types (BES/BIS/WiFI++).

 

Any suggestions on how I could make this work?

 

Best regards,

Per Ola

Please use plain text.
Developer
simon_hain
Posts: 16,207
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Connecting to network (HttpConnection) with BB OS 7 devices

welcome to the support forums

i suggest to use
http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/transport/ConnectionFactory...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Connecting to network (HttpConnection) with BB OS 7 devices

ConnectionFactory will simplify this for you if you are using OS 5.0 and above.

 

If you have to support previous OS's, then the approach you are using should work.

 

A few thoughts:

 

You say:

"I have an app that is using HttConnection with the plain URL (no parameters added) and it is working just fine for all BB devices up to devices running BB OS 7"

You have been lucky!  I don't think this would be the case for many people.

 

You say

"If I set it to just use TRANSPORT_WAP2 it will work on BB OS 7, but only if the WiFI is enabled."

I would say this is unusual and in fact I would report this as a bug.  But all OS 7.0 + devices I have tested work fine on WiFi, but only if the ";interface=wifi" is specified.  I would 100% confirm you are specifying the WAP connection string and I would turn mobile off on device to prove this is actually what you are seeing. 

 

Is there any reason why you don''t try WiFi before the other services.  I would put it before everything except MDS.

 

If you haven't specified the extra parameter, then BIS-B will not work. 

 

 

Please use plain text.
New Contributor
peroseth
Posts: 9
Registered: ‎02-23-2012
My Device: Developer

Re: Connecting to network (HttpConnection) with BB OS 7 devices

[ Edited ]

Thank you for the reply simon_hain.

 

I need to support devices running on BB OS earlier than 5.0 so that kinda removes the option you suggested. If I can't make it work for all devices I might go back to try this.

 

Best regards,

Per Ola

Please use plain text.
New Contributor
peroseth
Posts: 9
Registered: ‎02-23-2012
My Device: Developer

Re: Connecting to network (HttpConnection) with BB OS 7 devices

Hi peter_strange,

 

Thank you for the detailed reply, much appreciated.

 

You might be right that I have just been lucky when running with no parameters in the URL.

I tried again witht he WAP 2 transport and I was wrong. If I have WiFI enabled and disable the mobile then it does not work.

 

I changed the arangement of transport types so I am now trying:

  1. MDS
  2. WiFi
  3. BIS-B
  4. Default TCP Celluar
  5. WAP 2
  6. WAP 1

 

Running on a BB OS 6 device this works great with only mobile on, only wifi on and a combination of both.

Running on a BB OS 7 device it works with only wifi on, and a combination of wifi and mobile. But it does not work if I only have mobile on. With only mobile on I am able to surf with the browser and use apps like twitter and facebook so the mobile connection should be just fine.

 

Do you why it does not work on BB OS 7 when WiFi is disabled and mobile is on?

 

Best regards,

Per Ola

Please use plain text.
Developer
peter_strange
Posts: 19,608
Registered: ‎07-14-2008
My Device: Not Specified

Re: Connecting to network (HttpConnection) with BB OS 7 devices

In the absence of other information, my theory would be that the Browser and Twitter and Facebook, all RIM written, use BIS-B.  As I mentioned previously, BIS-B needs a special parameter which you have to ask for or get by using PUSH for your application, see:

http://supportforums.blackberry.com/t5/Java-Development/Sample-HTTP-Connection-code-and-BIS-B-Access...

 

In addition, you need to be aware that the working or not of the various connection methods is more typically a result of the carrier and plan rather than OS.  In the first instance I would investigate other factors for the difference you see between OS 7 and OS 6 rather than the OS level. 

 

Unfortunately I think the next course of action is to try out the network diagnostic tool.  I think you know where it is, but just in case, look for the attachments here:

http://supportforums.blackberry.com/t5/Java-Development/What-Is-Network-API-alternative-for-legacy-O...

Please use plain text.
New Contributor
peroseth
Posts: 9
Registered: ‎02-23-2012
My Device: Developer

Re: Connecting to network (HttpConnection) with BB OS 7 devices

Hi peter_strange,

 

Thanx a lot for the effort I see you put down in this forum and other places.

 

Your theory that the various connection issues was rather a result of the carrier and plan then the OS seems to be correct. I tried to switch the SIM-card between the OS 7 and OS 6 device and then it works just fine for the OS 7 device. The strange thing is that it also works fine with the OS 6 device (now using the SIM-card where mobile data did not work in the OS 7 device).

 

As you have probably understood I am getting a bit confused by the different BB network capabilites but after some reading and help from you I am starting to get there :smileyhappy:

 

I will look closer in to the BIS-B connection. I understand that this must be granted by BlackBerry Alliance for each app developed...

 

I might also run the network diagnostic tool to try to see why the OS 6 and OS 7 device behaves different even when using the same SIM-card.

 

Thanks a lot,

 

Per Ola

 

Please use plain text.
Developer
simon_hain
Posts: 16,207
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Connecting to network (HttpConnection) with BB OS 7 devices

you can apply for bis-push (which is free) and get access to BIS-B as a sideeffect.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
peroseth
Posts: 9
Registered: ‎02-23-2012
My Device: Developer

Re: Connecting to network (HttpConnection) with BB OS 7 devices

Is it possible to skip BIS-B (push) support and still be guarantied that it will work with all different carries/data plans?

 

Using this logic:

		TransportDetective td = new TransportDetective();
		URLFactory urlFactory = new URLFactory(gatewayURL);

		if(td.isCoverageAvailable(TransportDetective.TRANSPORT_MDS)){
			//Use MDS if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getSrMds());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_TCP_WIFI)){
			//Use TCP WIFI if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getTcpWiFiServiceRecord());
		}
		else if (td.isDefaultTcpCellularServiceRecordAvailable()){
			//Use default TCP Celluar Service if available (APN)
			gatewayURL = urlFactory.getHttpWap2Url(td.getDefaultTcpCellularServiceRecord());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_WAP2)){
			//Use WAP 2 if available
		    gatewayURL = urlFactory.getHttpWap2Url(td.getWap2ServiceRecord());
		}
		else if(td.isCoverageAvailable(TransportDetective.TRANSPORT_WAP)){
			//Use WAP 1 if available
		   gatewayURL = urlFactory.getHttpWap2Url(td.getWapServiceRecord());
		}

 We are already using a framework for communication which is using the HttpConnection. Looks like I would have to do quite a lot to use BIS push...

 

Cheers,

Per Ola

Please use plain text.
Developer
simon_hain
Posts: 16,207
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Connecting to network (HttpConnection) with BB OS 7 devices

i cannot guarantee you anything when it comes to networking, but most likely it should work without BIS, yes.
It's just that all RIM applications use BIS, and if other transports fail the customer sees "they work, yours do not".
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.