Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Java.io.IOException: Tunnel Failed for UDP connection

I don't like to sound like a nag, but try the 8900 simulator that comes with JDE 4.6.1. UDP works there for me. Period.

Developer
DAquilina
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Java.io.IOException: Tunnel Failed for UDP connection

It's clearly not just UDP -- It's any kind of connection. UDP, Browsing, email -- you name it, it doesn't work. Network says I have full bars, JDE links to the proper MDS directory, but when I go to manage connections, even though the main window says that they're all on the detail window says there's no connection for anything other than the basic CDMA.

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Java.io.IOException: Tunnel Failed for UDP connection

P.S. BTW, UDP is only supported for Wi-Fi TCP/UDP and Carrier TCP/UDP. UDP is not supported for MDS, BIS-B, and WAP transports.

Developer
DAquilina
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Java.io.IOException: Tunnel Failed for UDP connection

The fact that I don't know what that means shouldn't really matter... (Server connections and app development are both very new to me) It clearly works on the Storm simulator, which uses the same channels as the other simulators. What those channels might be is truly a mystery to me, but the fact that UDP packets can be sent/received in the same manner as the provided demo means there's some configurations with all of the other simulators that aren't quite functioning up to snuff. I should more clearly point out that the UDPDemo sample application has the exact same problem as the one I am writing -- Tunnel Failed. I actually only get that specific error response from the later simulators. The 8300/8330, for example, just says Java.io.IOException.

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: Java.io.IOException: Tunnel Failed for UDP connection

Developer
jack_black
Posts: 74
Registered: ‎01-03-2010
My Device: Not Specified

Re: Java.io.IOException: Tunnel Failed for UDP connection

Any help from anybody??

 

People are reporting UDP ok in 4.6.1 onward and about 8900 simulators.

But what will happen about others?

 

Direct TCP works in all of them. UDP is lower layer protocol, then why IOexception? Is it simulator bug or OS's?

 

We don't have so many devices to test but RIM should check this. Only relying on wi-fi and BES stuffs

don't really helps it's future in the edge of cloud computing.

Developer
DAquilina
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Java.io.IOException: Tunnel Failed for UDP connection

Hey Jack,

 

So my problem was resolved, but my code has evolved significantly since posting this topic. There were many, MANY fixes I tried, but I'm not sure where the simulator problems ended and my coding problems began. The step that finally fixed the issues I was experiencing was a bit of a code change. I modularized my code to constantly check if there was a connection to the server. If there was not a connection, it would try and connect. My UDPDatagramConnection was a global variable. Several Threads would start up almost simulataneously and find that the connection was not made, and so would all at once call the connectToServer method, which was synchronized. This caused several requests to enter the queue. The first call worked, but each subsequent call corrupted the global variable by trying to open a connection that was already open. Since the method was called based on a global flag (public static boolean connected), I added an if statement to check if there was a connection when the method was called, and if there was to return immediately/ignore the code:

 

 

/**
   * Opens a UDP Connection. If no connection can be made, the connection is
   * flagged for reference. This application should never try to send a packet
   * when the connection is invalid.
   */
  //Open a UDP Datagram Connection
  public static synchronized void connectToServer ()
  {
    if (!connected)
    {
      try
      {
        //Debug
        SentBM_UI.Assert ("Connecting...");
        
        //Staging server
        conn = (UDPDatagramConnection) Connector
               .open ("datagram://" + IP); // */
        
        connected = true;
      }
      catch (IOException e)
      {
        //Debug
        SentBM_UI.Assert ("Connection Failed");
        
        connected = false;
      }
      finally
      {
        //Debug
        SentBM_UI.Assert ("Connected to server: " + connected);
      }
    }
    else
    {
      //Debug
      SentBM_UI.Assert ("Already Connected");
    }
  }

I tell you this to point out that it's not always what you think. It took me two weeks of debugging and two very experienced programmers (vastly more talented than myself) to find this problem which I inadvertantly created. That said, the Simulators are far from perfect -- it's just a matter of making sure your code can handle the task you assign it.

 

 

Hope that helps,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Contributor
princykv
Posts: 38
Registered: ‎07-06-2010
My Device: BlackBerry Torch 9800

Re: Java.io.IOException: Tunnel Failed for UDP connection

Hi,

 

I have some issues in udp connection.

I want to broadcast a message to network. When I used general broadcast address 255.255.255.255, i am getting IO exception: String out of index. Why is it so?

 

code snippet:

 

UDPDatagramConnection _conn = (UDPDatagramConnection)Connector.open("udp://255.255.255.255:5555;3000/");

 

Note: My application works in wifi network. Do I need to specify APN here?If so how to find the APN name and its password?

 

Please send in your suggestions.

 

Thanks,

Princy