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

Direct TCP connection times out while sending data

by Retired on ‎02-17-2010 01:02 PM - edited on ‎11-22-2010 07:30 PM by (4,309 Views)

Summary

 

This article applies to the following:

  • BlackBerry® smartphones based on Java® technology

Problem

 

When sending a large amount of data in small sections, and frequently calling the write method with a small amount of data, an IOException is thrown stating that the direct Transmission Control Protocol (TCP) connection has timed out, even when the BlackBerry smartphone user remains in a wireless coverage area. Opening a new connection immediately allows data to be sent.

 

Cause

 

Every time the write method is called on a stream, a BlackBerry smartphone expects a TCP acknowledgement indicating that the destination server has received the data. Sending a large amount of data in very small sections by frequently calling the write method can result in a large number of TCP acknowledgements to be queued on the BlackBerry smartphone. This causes the buffer that queues these acknowledgements to overflow and results in lost TCP acknowledgements. The TCP acknowledgements are not received and the BlackBerry smartphone throws an IOException stating that the connection has timed out.

 

Resolution

 

To resolve this issue, you must lower the frequency of calls to the write method your application makes. The recommended approach is to queue the data within your application and send it in larger sections. There may be cases where this is not possible due to server-side limitations. In these situations you can insert sleep commands within the loop that is calling the write method.

 

Note: There are other possible causes for this exception, such as a BlackBerry smartphone user moving out of a wireless coverage area.

Contributors
Comments
by Developer
on ‎06-21-2010 05:41 AM - last edited on ‎06-22-2010 10:30 PM by Moderator

>>There may be cases where this is not possible due to server-side limitations. In these situations you can insert sleep commands within the loop that

>>is calling the write method.

 

 

Hi,

 

The above I did not understand. How sleep method is linked to TCP sockets and its timeout errors?

 

Could you  please elaborate?

 

Thanks & Best Regards,

Sudhakar C.

Sr. Architect  -  Mobile Computing Group.

 

 

 

 

 

by BlackBerry Development Advisor
on ‎06-21-2010 11:07 AM

Sleeping between rapid calls to write allows the BlackBerry Smartphone to process the TCP acknowledgements that are returned from the server you are sending data to, preventing the buffer from becoming full.

 

Basically you are throttling your write calls.

Users Online
Currently online: 30 members 1,459 guests
Please welcome our newest community members: