黑莓粗体隧道失败。 为什么?

发布于 2024-07-27 03:29:44 字数 246 浏览 5 评论 0原文

我创建了一个j2me程序并将其移植到黑莓bold上。

该程序执行一些 http 查询。 有时这些会失败,但有例外:“隧道失败”

我的 APN 设置是正确的(因为有时它确实有效)。

我通过附加到网址的“;deviceside=true”进行连接,

我注意到当浏览器刚刚处于活动状态时,程序始终可以运行。 但是,当浏览器几分钟没有激活并且我启动程序时,我收到隧道失败错误。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空名 2024-08-03 03:29:44

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

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

希望这可以解决你的问题

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

岁月如刀 2024-08-03 03:29:44

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

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?

还在原地等你 2024-08-03 03:29:44

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

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文