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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel
Accepted Solution

SSL connection to Server on Internet on BIS plan for Airtel

[ Edited ]

Dear experts,

 

I am a newbie in BlackBerry development and have come up with an application which needs users to register over https connection from BlackBerry.

 

I am testing the application on BlackBerry Bold 9000 with an OS upgrade to 5.0 version provided by carrier Airtel.

 

I have searched the numerous posts here and have tried using ConnectionFactory to ensure that I select the right Access point for the network. The registration works fine on WiFi.

 

However, im using a BIS plan and when I try to register OTA it fails

 

Any pointers based on code below and Event log for application would be really helpful.

 

 

int[] preferredTransportTypes = {TransportInfo.TRANSPORT_TCP_WIFI,
				TransportInfo.TRANSPORT_MDS, 
				TransportInfo.TRANSPORT_WAP2, 
				TransportInfo.TRANSPORT_TCP_CELLULAR,
				TransportInfo.TRANSPORT_BIS_B
				};

		ConnectionDescriptor conDescriptor = factory.getConnection(req.getUrl());
		HttpsConnection request=null;

		if ( conDescriptor != null ) {

			// connection suceeded
			int transportUsed = conDescriptor.getTransportDescriptor().getTransportType();

			Logger.log("Using transport type:" + transportUsed);

			// using the connection
			request = (HttpsConnection) conDescriptor.getConnection();
		}
		else
		{
			ServerResponse response = new ServerResponse();
			response.setErrorMessage("No connectivity to Server!");
			response.setStatusCode(-1);
			return response;
		}

		addHeaderParams(request, req);

		switch (req.getReqType()) {
		case RequestType.GET: {
			request.setRequestMethod(HttpConnection.GET);

			break;
		}
		case RequestType.POST:
		case RequestType.PUT: {
			request.setRequestMethod(HttpConnection.POST);
			addBodyParams(request, req);
			break;
		}

		}
		return executeRequest(request);

}

private static ServerResponse executeRequest(HttpsConnection request)
			throws Exception {

		ServerResponse resp = new ServerResponse();

		resp.setStatusCode(request.getResponseCode());



		if (request.getResponseCode() != HttpConnection.HTTP_OK) {
			resp.setErrorMessage(request.getResponseMessage());
		} else {
			InputStream is=null;
			try
			{
				is = request.openInputStream();

				int len = (int) request.getLength();
				if (len > 0) {
					int actual = 0;
					int read = 0;
					byte[] data = new byte[len];
					while ((read != len) && (actual != -1)) {
						actual = is.read(data, read, len - read);
						read += actual;
					}


					resp.setBody(new String(data).toString());
				}
				else if (len == -1)
				{
					StringBuffer out = new StringBuffer();
					byte[] b = new byte[4096];
					for (int n; (n = is.read(b)) != -1;) {
						out.append(new String(b, 0, n));
					}

					resp.setBody(out.toString());

				}
			}catch(Exception e)
			{
				Logger.log(e);
			}
			finally
			{
				if (is!=null)
					is.close();
			}


		}

		return resp;

	}

 

Below is the event log of the failed connection

 

i net.rim.networkapi - FatF net.rim.device.cldc.io.ssl.

TLSIOException(net.rim.device.api.crypto.tls.TLSAlertException) - 3/30 09:59:25
i net.rim.networkapi - Fatf   3 - 3/30 09:59:25
a TLSAlertProtocol - TLS:<-Alert - Level=2 Description=22 - 3/30 09:59:25
d net.rim.tcp - TXss - 3/30 09:59:25
d net.rim.tcp - TXsb   7 - 3/30 09:59:25
d net.rim.tcp - TXss - 3/30 09:59:25
d net.rim.tcp - TXsb   100 - 3/30 09:59:25
d net.rim.tcp - TXss - 3/30 09:59:24
d net.rim.tcp - TXsb   103 - 3/30 09:59:24
a net.rim.memclean - FrmF - 3/30 09:59:24
d net.rim.tcp - OPEN - 3/30 09:59:24
d net.rim.hrtRT - CNon - 3/30 09:59:21
d net.rim.hrtRT - PRjI - 3/30 09:59:21
a net.rim.hrtRT - EPRj 0x2100000002 - 3/30 09:59:21
d net.rim.tunnel - EStl   1 - 3/30 09:59:21
d net.rim.tunnel - EStl   1 - 3/30 09:59:21
d net.rim.tunnel - EStl   1 - 3/30 09:59:21
a net.rim.tunnel - STac-blackberry.net - 3/30 09:59:21
a net.rim.tunnel - Open-blackberry.net - 3/30 09:59:21
a net.rim.tcp - open tcpsocket://100.1.200.99:8080;interface=cellular;apn=blackberry.net;tunnelAuthUsername=;tunnelAuthPassword=;qos=0,0,0,0,0 - 3/30 09:59:21
d net.rim.http - Hcop - 3/30 09:59:21
d net.rim.http - Hcos - 3/30 09:59:21
d net.rim.http - Hcop - 3/30 09:59:21
d net.rim.http - Hcos - 3/30 09:59:21
d net.rim.networkapi - FcoC https://xyz.com:8443/services/rest/ProfileService/Profile/;deviceside=true;ConnectionUID=WAP2 trans - 3/30 09:59:21
i net.rim.networkapi - Fatt   3 - 3/30 09:59:21
i net.rim.networkapi - FatF net.rim.device.internal.io.CriticalIOException: Critical tunnel failure - 3/30 09:59:21
i net.rim.networkapi - Fatf   1 - 3/30 09:59:21
E net.rim.tcp - TNLf   0 - 3/30 09:59:21
a net.rim.tunnel - Clos-airtelgprs.com - 3/30 09:59:21
a net.rim.tunnel - STnc-00000000 - 3/30 09:59:19
a net.rim.tunnel - Open-airtelgprs.com - 3/30 09:59:19
a net.rim.tcp - open tcpsocket://xyz.com:8443;interface=cellular - 3/30 09:59:19
a net.rim.memclean - FrmF - 3/30 09:59:19
d net.rim.networkapi - FcoC https:/xyz.com:8443/services/rest/ProfileService/Profile/;deviceside=true - 3/30 09:59:19
i net.rim.networkapi - Fatt   1 - 3/30 09:59:19
i net.rim.networkapi - FatF net.rim.device.api.io.transport.InsufficientCoverageException: Insufficient Coverage - 3/30 09:59:19
i net.rim.networkapi - Fatf   6 - 3/30 09:59:19
i net.rim.networkapi - Fatt   6 - 3/30 09:59:19
i net.rim.networkapi - Tfil   3 - 3/30 09:59:19
d net.rim.networkapi - TadD WAP2 trans - 3/30 09:59:19
i net.rim.networkapi - Tadd   3 - 3/30 09:59:19
d net.rim.networkapi - TadD GPMDSEU01 - 3/30 09:59:19
i net.rim.networkapi - Tadd   5 - 3/30 09:59:19
d net.rim.networkapi - TadD S TCP-WiFi - 3/30 09:59:19
i net.rim.networkapi - Tadd   6 - 3/30 09:59:19
Please use plain text.
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel

Re: SSL connection to Server on Internet on BIS plan for Airtel

Update - when I tried to connect without ssl. Was able to connect via tcpsocket on BIS plan on airtel.

 

So it seems SSL does not work with direct sockets? Any experts?

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: SSL connection to Server on Internet on BIS plan for Airtel

Can you confirm that you are not in fact using a socket, but are using http as your connection protocol.

 

When you connect, which connection type are you in fact using?  I think we just need the output from this line:

Logger.log("Using transport type:" + transportUsed);

Please use plain text.
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel

Re: SSL connection to Server on Internet on BIS plan for Airtel

Transport type being used is - 3 (TRANSPORT_WAP2)

 

Does https work with TRANSPORT_WAP2

 

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: SSL connection to Server on Internet on BIS plan for Airtel

That is indeed a good question.  I suspect the answer might depend on your carrier, in this case Airtel.  Does their package allow port 443 through WAP?

 

The only way I know of testing this is to create a little socket based program and have it try port 60, which should work and then port 443.  But probably easiest to contact Airtel and ask. 

Please use plain text.
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel

Re: SSL connection to Server on Internet on BIS plan for Airtel

Thanks Peter_strange for your answer.

 

If it is carrier dependent then it is a bit frustrating to say the least. Even if we get through Airtel, we would have other carriers who would be doing things differently.

 

No wonder Android and iPhones are ruling the roost when it comes to apps inspite of RIM making some of the best devices.

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: SSL connection to Server on Internet on BIS plan for Airtel

If you can get BIS-B connectivity, then things become a little simpler. Are you an Alliance member?  Or do you have an application using push?

Please use plain text.
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel

Re: SSL connection to Server on Internet on BIS plan for Airtel

Thanks Peter_strange.

 

We are an early stage startup and no we are not an alliance member yet. It would probably be difficult for us to go through all the legal paraphrenalia and costs before we are able to prove our concept for BlackBerry devices in India.

 

Moreover there are other issues related to SMS messaging more specifically at this thread

http://supportforums.blackberry.com/t5/Java-Development/Unable-to-restore-messages-to-Sms-Inbox/td-p...

 

We may have to drop RIM as a platform altogether if there is no real answer to this other thread.

Please use plain text.
Developer
peter_strange
Posts: 17,713
Registered: ‎07-14-2008

Re: SSL connection to Server on Internet on BIS plan for Airtel

Understand, in which case you can get BIS-B by registering for a push application.  See here:

 

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

 

Regarding your SMS question, sorry I can't help.  Not an area of expertise. 

 

Good luck.

Please use plain text.
Contributor
garfield9791
Posts: 25
Registered: ‎03-30-2012
My Carrier: airtel

Re: SSL connection to Server on Internet on BIS plan for Airtel

Thanks for all the help Forum developers. It turns out, we were attempting SSL on non standard port. When we moved over to 443, we were able to go through Airtel and Vodfaone both.

Please use plain text.