1

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.

4

3 回答 3

2

一些黑莓设备的问题是所有其他网络连接都失败。因此,当您收到异常时,您将不得不再次尝试。所以你的连接代码应该是这样的

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++;
}

希望这可以解决您的问题

于 2009-08-04T05:28:33.270 回答
1

作为测试,您可能想尝试在 URL 本身上添加 APN 设置,看看是否有帮助。我假设你有很好的信号强度?

于 2009-07-15T16:49:19.157 回答
1

即使您只是从连接中读取,这听起来很愚蠢,请确保在打开连接器时将其打开为读/写

String url = "http://www.google.com";
HttpConnection connection = (HttpConnection)Connector.open(url, Connector.READ_WRITE, true);
于 2009-07-16T10:20:11.130 回答