03-30-2012 09:54 AM - edited 03-30-2012 11:05 AM
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().getTranspor tType();
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.
Solved! Go to Solution.
04-02-2012 03:10 AM
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?
04-02-2012 04:02 AM
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);
04-03-2012 12:38 AM
Transport type being used is - 3 (TRANSPORT_WAP2)
Does https work with TRANSPORT_WAP2
04-03-2012 03:39 AM
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.
04-03-2012 03:46 AM
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.
04-03-2012 04:05 AM
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?
04-03-2012 04:11 AM
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
We may have to drop RIM as a platform altogether if there is no real answer to this other thread.
04-03-2012 04:25 AM
Understand, in which case you can get BIS-B by registering for a push application. See here:
Regarding your SMS question, sorry I can't help. Not an area of expertise.
Good luck.
04-16-2012 07:29 AM
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.