BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-02-2008, 05:12 PM   #1 (permalink)
New Member
 
Join Date: Dec 2008
Model: Bold
PIN: N/A
Carrier: ATT
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default httpConnection results in java.io.IOException: Timed out

Please Login to Remove!

I've gone through almost all the httpConnection related issues discussed in this forum. I'm having this problem of "Timed Out" at the Connector.open() call. I tried several URLs and none works.

conn = (HttpConnection) Connector.open(url);
conn.setRequestMethod(requestMode);

out = conn.openOutputStream();
out.write(data.getBytes());
out.flush();

responseCode = conn.getResponseCode();

just to clarify, I have lessthan 50 buyes in my data payload. The timeout happens approximately after 20 seconds, not after 2 minutes. I tried with several URLs just for testing, it always times out. I'm using GET mode. I'm trying this on my BOLD. The code works fine in my simulator. not time outs in the simulator with the same URL. Anyhelp?

thanks,

Last edited by ggovind : 12-02-2008 at 11:55 PM.
Offline  
Old 12-04-2008, 12:16 AM   #2 (permalink)
New Member
 
Join Date: Dec 2008
Model: Bold
PIN: N/A
Carrier: ATT
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting to BIS-B helped, but get HTTP_LENGTH_REQUIRED

One of the developer suggested BIS-B setting and that seems to addressed the timed out issue. However I get 411 which is HTTP_LENGTH_REQUIRED error. I set the length with

conn.setRequestProperty("Content-Length", Integer.toString(data.length()));


the new code looks like,

StreamConnection s = (StreamConnection) Connector.open(url + ";deviceside=false;ConnectionType=mds-public");
conn = (HttpConnection) s;


if (conn == null) {
return ("Could not create Connection.");
}

conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("Content-Length", Integer.toString(data.length()));


out = conn.openOutputStream();
out.write(data.getBytes());
out.flush();

responseCode = conn.getResponseCode();

if (responseCode != HttpConnection.HTTP_OK) {
sendResult = false;
responseContent = null;
} else {
sendResult = true;
// System.out.println("http: connection ok.");
getResponseContent( conn );
}




any clue?

thanks,
Guna

Quote:
Originally Posted by ggovind View Post
I've gone through almost all the httpConnection related issues discussed in this forum. I'm having this problem of "Timed Out" at the Connector.open() call. I tried several URLs and none works.

conn = (HttpConnection) Connector.open(url);
conn.setRequestMethod(requestMode);

out = conn.openOutputStream();
out.write(data.getBytes());
out.flush();

responseCode = conn.getResponseCode();

just to clarify, I have lessthan 50 buyes in my data payload. The timeout happens approximately after 20 seconds, not after 2 minutes. I tried with several URLs just for testing, it always times out. I'm using GET mode. I'm trying this on my BOLD. The code works fine in my simulator. not time outs in the simulator with the same URL. Anyhelp?

thanks,

Last edited by ggovind : 12-04-2008 at 12:19 AM.
Offline  
Old 12-04-2008, 08:05 PM   #3 (permalink)
New Member
 
Join Date: Dec 2008
Model: Bold
PIN: N/A
Carrier: ATT
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default my mistake. set the data payload in GET

Finally found the problem with the HTTP_LENGTH_REQUIRED. Eventhough I set the mode to GET, if I had data in the payload, it treats it like POST and messed up the request. I tried with POST, that worked nicely (on making the http request part), then I went and removed the payload, put everything inthe URL and called GET. this also worked fine.

Working on reading the inputStream where I still have problem receiving the what the Web Service returning.

-Guna

Quote:
Originally Posted by ggovind View Post
One of the developer suggested BIS-B setting and that seems to addressed the timed out issue. However I get 411 which is HTTP_LENGTH_REQUIRED error. I set the length with

conn.setRequestProperty("Content-Length", Integer.toString(data.length()));


the new code looks like,

StreamConnection s = (StreamConnection) Connector.open(url + ";deviceside=false;ConnectionType=mds-public");
conn = (HttpConnection) s;


if (conn == null) {
return ("Could not create Connection.");
}

conn.setRequestMethod(HttpConnection.GET);
conn.setRequestProperty("Content-Length", Integer.toString(data.length()));


out = conn.openOutputStream();
out.write(data.getBytes());
out.flush();

responseCode = conn.getResponseCode();

if (responseCode != HttpConnection.HTTP_OK) {
sendResult = false;
responseContent = null;
} else {
sendResult = true;
// System.out.println("http: connection ok.");
getResponseContent( conn );
}




any clue?

thanks,
Guna
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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