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: 18
Registered: ‎03-10-2009
My Device: Not Specified

This a guaranteed http connection approach? Feedback needed!

[ Edited ]

Hi All,

 

I've created following two methods for reliably building a connection for making a data connection. So far I haven't had any issues testing this approach with users.

 

I'd love to get some community feedback about this approach and letting me know if anything seems in buildConnectionString(). Please see code below:

 

 

	private static String buildConnectionString()
	{

		//The Device is a simultaor --> TCP
		if (DeviceInfo.isSimulator())
			return ";deviceside=true;ConnectionTimeout=20000";

		String st = "";

		//A carrier is providing us with the data service
		if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
		{

			// blackberry internet service
			ServiceRecord rec = getBIBSRecord();//Apply for BIS access to get info about BIS recordset
			if (rec != null)//couldn't find the right record
				st = "[THIS CONNECTION STRING IS REMOVED, PLEASE APPLY FOR BIS ACCESS TO GET THIS STRING]";
			else if(GetWap2().length() > 0)
				st = GetWap2();
			else
				st = ";deviceside=true";// let the phone try to do the work

		}
		else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS)
			st = ";deviceside=false";// use the clients blackberry enterprise server
		else
			st = ";deviceside=true";// let the phone do the work if it can

		return st + ";ConnectionTimeout=45000";
	}

	public static String GetWap2() {
		String wap2Postfix = "";
		final ServiceBook sb = ServiceBook.getSB();
		final ServiceRecord[] records = sb.findRecordsByCid("WPTCP");

		for (int i = 0; i < records.length; i++) {
			// Search through all service records to find the valid non Wi-Fi
			// WAP 2.0 Gateway Service Record.
			if (records[i].isValid() && !records[i].isDisabled()
					&& records[i].getUid() != null
					&& records[i].getUid().length() != 0
					&& records[i].getUid().toLowerCase().indexOf("wifi") == -1
					&& records[i].getUid().toLowerCase().indexOf("mms") == -1) {
				wap2Postfix = ";ConnectionUID=" + records[i].getUid();
				break;
			}//endif
		}//end for
		return wap2Postfix;
	}// end wap postfix

 

 

Possible questions to consider:

 

  • If a BIS string exists (recordset found), will it always work (aside from being blocked by a corporate network)?
  • If a WAP2 string exists (recordset found), will it always work (aside from being blocked by a corporate network)?
  • Should I check for MDS support first as opposed to carrier support?
  • Beyond extreme cases where carriers block a connection,  will the above approach work?

Let me me know!

 

 

New Developer
Posts: 18
Registered: ‎03-10-2009
My Device: Not Specified

Re: This a guaranteed http connection approach? Feedback needed!

No feedback?

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

Re: This a guaranteed http connection approach? Feedback needed!

Some quick comments, hopefully I will come back to this.

 

I suggest you review the second Networking video for some helpful hints:

http://www.blackberry.com/DevMediaLibrary/view.do?name=NetworkingTransportsII

 

A good start I think for an automatic specification of the connection.  WiFi is missing.  I think BES/MDS should be chosen first if it is available.  You need to have an option where you specify nothing at all, I find on some phones that works, where deviceside=true and deviceside=false doesn't.

 

My answers to your questions:

 

1) If a BIS string exists (recordset found), will it always work (aside from being blocked by a corporate network)?

A: In corporate world I would use MDS first.  You can get transcoder problems with incorrect header values
2) If a WAP2 string exists (recordset found), will it always work (aside from being blocked by a corporate network)?

A: In corporate world I would use MDS first.  More likely to get transcoder problems as carriers try to optimize their networks
3) Should I check for MDS support first as opposed to carrier support?

A: I think so
4) Beyond extreme cases where carriers block a connection,  will the above approach work?

It is pretty similar to the automatic connection code I have.  However I also allow the user to specify the connection they will use regardless.  This is important I think, automatic is fine but if it has a choice then to give the user a consistent experience you might want to always use the same mechanism.

Highlighted
New Developer
Posts: 18
Registered: ‎03-10-2009
My Device: Not Specified

Re: This a guaranteed http connection approach? Feedback needed!

Hi Peter,

 

this is amazing feedback, this is all really great!