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
snebor
Posts: 3
Registered: ‎10-15-2009
My Device: Not Specified

SocketConnection not sending data on a non-simulator

I am trying to send data over a socket connection.  The code I have written works very well in the simulator, but when I run on an actual phone (Blackberry bold), I am having troubles.

 

The snippet of relevant code is

SocketConnection sc;

if(DeviceInfo.isSimulator())
{

  sc = (SocketConnection)Connector.open("socket://<myhostname>:11001;deviceside=true");

}

else

{
  sc = (SocketConnection)Connector.open("socket://<myhostname>:11001;deviceside=false;connectionUID=<myDevicesUID>;");
}

OutputStreamWriter out;

out = new OutputStreamWriter(sc.openDataOutputStream());

 

while loop (looping through a list of messages)

{

  //get and write a message (ending with \r\n)

  out.write(message, 0, message.length());

  out.flush();

}

 

 

Using the simulator, my server receives every message that is sent.  On an actual phone, I see the following

- Usually (but not always), a connection is established to my server

- Usually (but not always), I receive the first message

- Sometimes I receive the next 1 or 2 messages

- I never receive further messages after that

 

I have added logging to the blackberry event logger, and it shows that I have a valid connection, and that data is being sent over that connection for every one of my messages (the event logger says "a net.rim.ippp - TXst <msgSize")

.  

 

I have also tried experimenting with different connection strings, none of which have given me better results

 

 

Has anyone ran into this, and does anyone have any suggestions

Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

What does your MDS log say? May be the data gets to the MDS, but the MDS isn't forwarding it...
Please use plain text.
New Developer
snebor
Posts: 3
Registered: ‎10-15-2009
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

Unfortunately I'm not an a blackberry enterprise server, and I don't believe I have access to see the MDS log
Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

[ Edited ]

After you establish the connection, kick off a thread that will be constantly reading from the connection. If you don't read from the connection, you might not be receiving some errors associated with the connection.

 

P.S. I'm a bit concerned that you called the connection UID "My Device's UID". The UID is actually the UID of the BES/MDS you're trying to connect to. Are you using the right UID? The UID is usually that of the IPPP Service Book over the BES/MDS.

Message Edited by klyubin on 15-10-2009 10:20 PM
Please use plain text.
New Developer
snebor
Posts: 3
Registered: ‎10-15-2009
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

Thanks for the hint, but unfortunately, it didn't help much.  I don't see any exceptions being thrown from my read thread
Please use plain text.
Developer
Posts: 1,474
Registered: ‎04-14-2009
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

If you don't have access to the BES/MDS and the firewall behind which it's located then you're stuck (try switching the Event Log to Debug level, running your test, and then checking whether there's anything suspicious in the log). If you do have access to the internal network accessible from the MDS, try moving your server there and see whether it makes a difference...
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: SocketConnection not sending data on a non-simulator

You have added ";deviceside=true" but you have not appended any carrier-specific convection info, such as the APN or WAP gateway.

 

On most carriers, this will not work.

 

What carrier are you on?

 

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: SocketConnection not sending data on a non-simulator

Try direct TCP see if it works. I have the same problem before I updated the software on my Bold, but I have not tried it yet after the update. TCP send just seemed to stall after a megabyte or so of transmission, but receive is OK.  I am now using reliable transmission over UDP, a library I wrote a few years ago, and it is very fast as well.
Please use plain text.