BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 12-02-2008, 06: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-03-2008 at 12:55 AM.
Offline  
Old 12-04-2008, 01: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 01:19 AM.
Offline  
Old 12-04-2008, 09: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

A.O. Smith F48T04A50 Blower Motor 115V 1/2HP 1075RPM 4SPD w capacitor
$95.0
A.O. Smith F48T04A50 Blower Motor 115V 1/2HP 1075RPM 4SPD w capacitor pictureDayton 2C647 Rectangular Permanent Split Capacitor OEM Specialty Blower
$102.08
Dayton 2C647 Rectangular Permanent Split Capacitor OEM Specialty Blower  picture16mm x 1.5 Metric Left hand Die M16 x 1.5mm Pitch
$12.94
16mm x 1.5 Metric Left hand Die M16 x 1.5mm Pitch pictureCBB61 24uF 350 V AC Small gasoline Generator 50/60Hz SH capacitor HI
$7.48
CBB61 24uF 350 V AC Small gasoline Generator 50/60Hz SH capacitor HI picture5PC 63V 680uF High Frequency Radial Electrolytic Capacitors 13X25mm
$0.58
5PC 63V 680uF High Frequency Radial Electrolytic Capacitors 13X25mm picture






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