tunnel failed in blackberry bold. why?

冷暖自知 提交于 2019-12-08 07:17:06

问题


I created a j2me program and ported it to the blackberry bold.

The program does some http queries. Every now and then these fail with the exception: 'tunnel failed'

My APN settings are correct (since sometimes it does work).

I connect with ';deviceside=true' appended to the url

I notice that when the browser has just been active, the program always works. However when the browser hasn't been active for some minutes and I start the program, I get the tunnel failed errors.


回答1:


The problem with a few blackberry devices is that every other network connection fails. So you will have to try it once more when you receive an exception. So your connection code should be something like this

int numAttempts = 0;
boolean hasConnectedSuccessfully = false;
while(numAttempts < 2 && !hasConnectedSuccessfully)
{
   try
   {
     // do the http connection
      hasConnectedSuccessfully = true;
   }
   catch(Exception e)
   {
      hasConnectedSuccessfully = false;
   }
   finally
   {
     //close the connections
   }
   numAttempts++;
}

Hope this should fix your problem




回答2:


As a test, you might want to try adding the APN settings on the URL itself to see if that helps. I assume you have good signal strength?




回答3:


As silly as this sounds even if you are only reading from the connection, make sure when opening the connector you open it as read/write

String url = "http://www.google.com";
HttpConnection connection = (HttpConnection)Connector.open(url, Connector.READ_WRITE, true);


来源:https://stackoverflow.com/questions/1126018/tunnel-failed-in-blackberry-bold-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!