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: 79
Registered: ‎09-15-2008
My Device: Not Specified

Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

Hi,

 

My blackberry Curve 8320 with version 4.5.0.69  gives me TCP time out Excpetion. when i try to send contineous data on the DataOutputstream. with the previous version it was working fine.

This Exception are random it gives me...

Bad socket ID, Bad Tunnel ID with TCP time out Exception. Only when when i try to write data in a loop Receving is fine .only writing gives error.

 

Thanks

Alkesh Shroff

 

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

What route is your connection being made over?  The following link explains the routes available.

 

What Is - Different ways to make an HTTP or socket connection
Article Number: DB-00396

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What_Is...

 

When you receive this exception, are you able to reconnect or is the BlackBerry unable to send data even on a new connection?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 79
Registered: ‎09-15-2008
My Device: Not Specified

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

I am using Direct TCP stack with deviceside true and the code is

 

try

{

_conn = (SocketConnection)Connector.open(
url,

Connector.READ_WRITE,
true

);

//

_conn.setSocketOption( SocketConnection.KEEPALIVE, 1 );

 _conn.setSocketOption( SocketConnection.LINGER, 5 );
}

url is  :   socket://66.18.118.80:80;deviceside= true;apn=(WapGatewayAPN);TunnelAuthUsername=();TunnelAuthPassword=();

 

The TCP timeout exception is always in 8320 while in Bold 9000 i find it random say if contineous sync is for more than 10 mins. 

 

Once the exception is recived yes i am able to reconnect on a new connection. but again sending the contineous data will give same exception.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

[ Edited ]

Are you sending data continuously during this time or in spurts?  What network are you testing on?

 

Is the APN you are pointing to an actual WAP Gateway or the APN for direct TCP connections? You should use a direct TCP APN when using deviceside=true.

Message Edited by MSohm on 09-16-2008 03:50 PM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 79
Registered: ‎09-15-2008
My Device: Not Specified

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

I am sending the Data contineously. On contineous sending i guess the connection gets closed while writing on dataoutputStream and thats the reason after 2 mins it gives me. TCP time out.

If i use try catch block it gives me Bad socket ID or Bad Tunnel ID exception. and then the TCP exception

I am using ATT network.

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

Are you able to reproduce this in the BlackBerry Simulator?  Do you see it on multiple devices or just this one?  Or is this the only device you have tested on so far?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 79
Registered: ‎09-15-2008
My Device: Not Specified

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

On Berry 8320 Curve , This Exceptions is always. while on Berry Bold 9000 i find it very random say 1 out 10.

I didnt tested it on the simulator.

I can reproduce it on the actual device.

Is there a way to keep the connection alive always untill i close it ?

because this connection drop is the only reason i guess and in between the loop i cant open the connetion again.

Even i tried that but it gives me the same Exception.

 

Thanks,

Alkesh

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

[ Edited ]
Can you post some sample code of your loop that is sending data?  There is no way to keep a connection open forever.  It can be closed by the BlackBerry or wireless network if it is not in use.  It can also be closed by the wireless network after a specific length of time.  These times can vary based on a carrier's settings.
Message Edited by MSohm on 09-17-2008 04:28 PM
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 79
Registered: ‎09-15-2008
My Device: Not Specified

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

THis writeContact is Called in Loop say for 1000 times.And for me the Excetpion is mostly at 

dos.write(deviceInfo, 0, deviceInfo.length); in the code

and at times

dos.write(byteArray, 0, byteArray.length);

 

public static void writeContact( DataOutputStream dos, ContactDTO contact ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream buf = new DataOutputStream(baos); long bitMask = getBitMask(contact); buf.writeLong(bitMask); long recordId = contact.getRecordId(); buf.writeLong(recordId); /* * Write standard fields */ for (int i = 0; i < FLAG_FIELD_MAP.length; i++) { /* * Only write the field if its in our bitmask */ if ((bitMask & FLAG_FIELD_MAP[i]) == FLAG_FIELD_MAP[i]) { final String currFieldValue = contact.getFieldValue(FLAG_FIELD_MAP[i]); writeVarField(buf, currFieldValue, i); } } /* * Write number of values the phone contains in the format <num tel #s>:<num emails>:<num addrs> */ writeVarField(buf, contact.getNumFieldValues(), -1); int recordSize = baos.size() + 2; dos.writeShort(recordSize); final byte[] byteArray = baos.toByteArray(); dos.write(byteArray, 0, byteArray.length); /* * Write generic fields (specific to device) */ byte[] deviceInfo = contact.getDeviceInfo(); if (deviceInfo != null && deviceInfo.length > 0) { short extraLength = 2; extraLength += deviceInfo.length; dos.writeShort(extraLength); dos.write(deviceInfo, 0, deviceInfo.length); dos.writeShort(0); //End record dos.flush(); if(baos != null){ baos.close(); } if(buf != null){ buf.close(); } baos = null ; buf = null; // }

This is the Code sample.

u mentioned about the Carrier's settings, can we change it ?

 

I appreciate for ur help

Thanks

Alkesh

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Blackberry Curve 8320 giving Socket I/O Exception "TCP Timeout Excpetion"

Has the DataOutputStream you are using been opened (Connector.open) in the same thread that is executing your loop?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker