BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-19-2009, 08:32 AM   #1 (permalink)
New Member
 
Join Date: Apr 2009
Model: 7100
PIN: N/A
Carrier: Rogers
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default TCP read timed out exception on HttpConnection

Please Login to Remove!

I have a 8820 running OS v4.5.0.81. When running my http client application, the device throws IOException (TCP read timed out) every ~60 seconds. The code is like this:

HttpConnection conn = (HttpConnection) Connector.open(url, Connector.READ | Connector.WRITE, true);
//Some initialization code setting conn parameters
try {
int rcc = conn.getResponseCode();
} catch (Exception e) {
//got TCP read timed out exception here
}

Note that the same application doesn't have the ~60 seconds timeout exception on other devices.

Anyone knows how to extend timeout value on the device side? I need to request my application to wait for ~5 minutes for a http connection before timeout.

Thanks a lot.

Robin
Offline  
Old 05-19-2009, 10:53 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

First have a read through this thread. Posting your code this way makes it much easier to read. As you can see:

Quote:
Originally Posted by robinware View Post
I have a 8820 running OS v4.5.0.81. When running my http client application, the device throws IOException (TCP read timed out) every ~60 seconds. The code is like this:

Code:
HttpConnection conn = (HttpConnection) Connector.open(url, Connector.READ | Connector.WRITE, true);
//Some initialization code setting conn parameters
try {
    int rcc = conn.getResponseCode();
} catch (Exception e) {
    //got TCP read timed out exception here
}
Note that the same application doesn't have the ~60 seconds timeout exception on other devices.

Anyone knows how to extend timeout value on the device side? I need to request my application to wait for ~5 minutes for a http connection before timeout.

Thanks a lot.

Robin
Second, is there a particular reason you are opening the connection like this:
Code:
HttpConnection conn = (HttpConnection) Connector.open(url, Connector.READ | Connector.WRITE, true);
when the API documentation suggests:
Code:
HttpConnection conn = (HttpConnection)Connector.open(url);
You can neither read nor write directly on the HttpConnection so the additional parameters are at least superfluous, and may be causing problems.

Third, are you doing this on a thread that is not the main event thread?

And finally there is a knowledge base document on setting connection timeouts here.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 05-22-2009, 05:18 PM   #3 (permalink)
New Member
 
Join Date: Apr 2009
Model: 7100
PIN: N/A
Carrier: Rogers
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you hrbuckley for your information, which is very helpful.

I have made sure I followed all your suggestions. However, when I followed the RIM knowledge base document (I can't post link here. Please find the link in hrbuckley's post), I now got "net.rim.device.cldc.io.ippp.SocketBaseIOException : Connection Timed Out" problem when my HttpConnection waits ~2 minutes. My settings are:
* My device application connects to Http server through BES
* My device is 8820
* My code is
Code:
url = myUrl + ";ConnectionTimeout=600000;deviceside=false";
StreamConnection s = (StreamConnection)Connector.open(url);
HttpConnection httpConn = (HttpConnection)s;
try {
    int rcc = httpConn.getResponseCode();
} catch (Exception e) {
    //got Connection Timed Out exception here
}
Any help is appreciated!
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.