I wrote a simple BB app that does an HTTP Request and downloads some JSON encoded information. When I run it on the emulator with the ";deviceSide=true" after the URL it works OK. But when I tried it in my BlackBerry Storm actual device, I got the following exception:
java.io.IOException: No tunnels to open
Here's the code I use to do the HTTP Request:
public static String doHttpRequest(String addr) {
HttpConnection hConn = null;
DataInputStream dis = null;
String strData = "";
try {
hConn = (HttpConnection)Connector.open( addr );
dis = new DataInputStream(hConn.openInputStream());
//Get the string in the stream
int c;
while ( (c = dis.read()) != -1 ) {
strData = strData + (char) c;
}
}catch (Exception e) {
net.rim.device.api.ui.component.Dialog.alert( e.toString() );
开发者_StackOverflow中文版 } finally {
try{
if(dis != null) dis.close();
if(hConn != null) hConn.close();
} catch(Exception e) {
net.rim.device.api.ui.component.Dialog.alert( e.toString() );
}
}
return strData;
}
It seems you have some APN issues, you should reconfigure this part.
In general if your code works well on an emulator the chances are that your will need some configuration tweaks on your phone.
Resources :
- blackberryforums - Java.io.IOException:could not open tunnel - failed exception
- crackberry.com - Youtube and Storm 2?
Colin, Please append this string - ";deviceside=true;interface=wifi" after the url. It should work. I found a problem similar to this. I change this setting. And now, It is working. :-)
精彩评论