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
New Developer
Posts: 13
Registered: ‎03-01-2009
My Device: Not Specified

Fledge IP local address set to 0.0.0.0 makes it impossible for me to test outside of my Intranet...

While using the Simulator, one wants to be as respectful as possible as what we will be thrown out there in the real life. Fledge binds to local IP address 0.0.0.0 (see picture lower or at http://www.speechvibe.com/Temp/FledgeScreen.JPG). On the other hand, my router has a firewall in it (as most out there), and it is on a subnet 192.168.1.X. It is then impossible for me to forward the packets coming at a given port that I am listening on to the simulator since it is not on my subnet.

 

Am I missing something? Are there any parameters I can tweak on Fledge in order to make it register on my subnet instead?

 


FledgePorts

 

Another question: Is the network throuput simulating the type of performance that could be expected from a real device (are there some bandwidth limits that are set internally to provide a good reproduction of what a real device could result as)?

 

Thank you.

New Developer
Posts: 13
Registered: ‎03-01-2009
My Device: Not Specified

Re: Fledge IP local address set to 0.0.0.0 makes it impossible for me to test outside of my Intranet

I did find a IP Address filed under the Network tab of the Simulator tab within the preferences of the JDE. If I enter my IP address in there (192.168.1.103), I observe that Fledge now binds to that IP address instead of 0.0.0.0.

 

That being said... I still do not get anything from my router even though it is configured to forward these packets to my IP.

 

I am at a lost on this and would appreciate some tips if I am missing somthing (which obviously I am).

 

Router

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Fledge IP local address set to 0.0.0.0 makes it impossible for me to test outside of my Intranet

Can you tell us what you are trying to achieve? 

 

Remember that to push to the device, you actully push to the BES, not the device. 

New Developer
Posts: 13
Registered: ‎03-01-2009
My Device: Not Specified

Re: Fledge IP local address set to 0.0.0.0 makes it impossible for me to test outside of my Intranet

I am testing my functional application under real-world public IP settings. Already, the application works flawlessly when within my Intranet (domain 192.168.1.X). But when I change my settings for the packets to go in the real world behond my router, all Hells beaks lose.

 

Here is some coding snippets of how I am achieving my stuff.

 

1) Opening my sockets...

 

UDPDatagramConnection m_socket = (UDPDatagramConnection)Connector.open(m_connectorReceiveAddress, Connector.READ_WRITE, true);

 

When dealing with the Intranet only, m_connectorReceiveAddress is UDPRepeaterCommunicationLayerClass.GetLocalIP() + ":7180;3000" where GetLocalIP is defined as following (returns "192.168.1.103" as expected):

 

public static String GetLocalIP()
    {
        String dReturn = "";
        UDPDatagramConnection dSocket = null;
        try
        {
            dSocket = (UDPDatagramConnection)Connector.open(UDPRepeaterCommunicationLayerClass.m_protocol + "://cnn.com:80", Connector.READ_WRITE, true);
            if (dSocket != null)
            {
                dReturn = dSocket.getLocalAddress().toString();
            }
        }
        catch (Exception e) {}
        finally
        {
            if (dSocket != null)
            {
                try
                {
                    dSocket.close();
                }
                catch (Exception e) {}
            }
        }
        return dReturn;
    }

 

When dealing with the Internet, m_connectorReceiveAddress is UDPRepeaterCommunicationLayerClass.GetPublicIP() + ":7180;3000" where GetPublicIP is defined as following (returns the router address as expected):

public static String GetPublicIP()
    {
        String dReturn = "";
        StreamConnection c = null;
        InputStream s = null;
        try {
            c = (StreamConnection)Connector.open("http://whatismyip.com/automation/n09230945NL.asp");
            s = c.openInputStream();
            int ch;
            while ((ch = s.read()) != -1)
            {
                dReturn += (char)ch;
            }
        }
        catch (IOException e) {}
        finally
        {
            try
            {
                if (s != null)
                {
                    s.close();
                }
                if (c != null)
                {
                    c.close();
                }
            }
            catch (IOException e) {}
        }
        if (dReturn.endsWith("\n"))
        {
            dReturn = dReturn.substring(0, dReturn.length() - 1);
        }
        return dReturn;
    }

2) Whenever it is time to send some data, I do the following (as an example):

    protected synchronized void DeliverACK(String toAddress, int dMessageId, int curPacket) throws IOException
    {
        String dContent = dMessageId + "." + String.valueOf(curPacket);
        byte[] dDataBytes = dContent.getBytes();
        synchronized(UDPRepeaterCommunicationLayerClass.m_threadMutex)
        {
            if (m_socket != null)
            {
                Vector dPackets = WrapMessage(m_address, CommunicationInterface.eMsgTypeCommLayerACK, dDataBytes, kMaxPacketSize, false);
                for (int i = 0; i < dPackets.size(); i++)
                {
                    Datagram dNewDatagram = m_socket.newDatagram(((byte[])dPackets.elementAt(i)), ((((byte[])dPackets.elementAt(i))).length));
                    dNewDatagram.setAddress(UDPRepeaterCommunicationLayerClass.m_protocol + "://" + toAddress);
                    if (PhoneInputMidlet.m_debug) System.out.println("calling send from DeliverACK (messageID: " + dMessageId + "." + curPacket + ")");
                    m_socket.send(dNewDatagram);
                    if (PhoneInputMidlet.m_debug) System.out.println("send call succeeded");
                    m_bytesUsed += (long)((((byte[])dPackets.elementAt(i))).length);
                    if (m_receiveThreadDelegate != null)
                    {
                        m_receiveThreadDelegate.CommunicationActivity(MessageProcessable.eSentData);
                    }
                }
            }
        }
    }

3) And, I have a thread that listens for incoming data:

    private boolean DoOneReceiveCycle() throws IOException
    {
        boolean gotOne = false;
        int keepPriority = Integer.MIN_VALUE;
        try
        {
            if (m_socket != null)
            {
                PerformPeriodicalTasks();
                Datagram dDatagram = m_socket.newDatagram(GetMaxPacketSize());
                dDatagram.reset();
                byte[] dBuffer = new byte[GetMaxPacketSize()];
                dDatagram.setData(dBuffer, 0, GetMaxPacketSize());
                int dAwaitingMesID = m_nextMessageId;
                if (PhoneInputMidlet.m_debug) System.out.println("Calling receive, awaiting messageId " + dAwaitingMesID + ", in queue: m_messagesToProcess -> " + m_messagesToProcess.size() + " messages, m_queuedMessages -> " + m_queuedMessages.size() + "[" + getMesDescs() + "]");
                PerformPeriodicalTasks();
                if ((m_UDPreceiveThread == Thread.currentThread()) && (m_receiveStallThread != null))
                {
                    keepPriority = m_UDPreceiveThread.getPriority();
                    m_UDPreceiveThread.setPriority(kUDPThreadPriorityReceive);
                    m_receiveStallThread.setPriority(kUDPThreadPriorityReceive);
                }
                m_lastReceiveCall = new Date();
                m_socket.receive(dDatagram);
   ...