BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 09-06-2010, 01:05 PM   #1 (permalink)
New Member
 
Join Date: Aug 2010
Model: 7100T
PIN: N/A
Carrier: Orange
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Connection Closed When trying to post over 1K of url encoded data

Please Login to Remove!

From the simulator, this all works.



I'm using wifi on the device as i'm assuming it's the most stable.



The problem occurs when i try to post more than 1K of urlencoded data.



If i send less then it's fine.



It seems to hang the .flush command();



I've written a small testapp, and using the main thread so i know that it's not threads getting confused



If anyone has any ideas that would be great.



Here is the code:

[code]
private String PostEventsTest()
{
String returnValue = "Error";
HttpConnection hc = null;
DataInputStream dis = null;
DataOutputStream dos = null;
StringBuffer messagebuffer = new StringBuffer();
URLEncodedPostData postValuePairs;
try
{

postValuePairs = new URLEncodedPostData(null, false);
postValuePairs.append("DATA",postData);// postData);
hc = (HttpConnection) Connector.open(postURL, Connector.READ_WRITE);
hc.setRequestMethod(HttpConnection.POST);
hc.setRequestProperty("User-Agent", "BlackBerry");
hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
hc.setRequestProperty("Content-Length", Integer.toString(postValuePairs.getBytes().length) );
//hc.setRequestProperty("Content-Length", Integer.toString(postData.length()));



dos = hc.openDataOutputStream();
dos.write(postValuePairs.getBytes());
dos.flush();
dos.close();
// Retrieve the response back from the servlet
dis = new DataInputStream(hc.openInputStream());
int ch;
// Check the Content-Length first
long len = hc.getLength();
if (len != -1)
{
for (int i = 0; i < len; i++)

if ((ch = dis.read()) != -1)
messagebuffer.append((char) ch);
}
else
{ // if the content-length is not available
while ((ch = dis.read()) != -1)
messagebuffer.append((char) ch);
}
dis.close();
returnValue = "Yahoo";
}
catch (Exception ex)
{
returnValue = ex.toString();
ex.printStackTrace();
}

return returnValue;

}


[code]
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

Clean RAM R-100 Heavy Duty Sheet Metal Shears "Nibbler" 18 ga Milled Steel
$54.95
Clean RAM R-100 Heavy Duty Sheet Metal Shears HOSPITAL COMPUTER TOUCH SCREEN INTEL ATOM D525 @ 1.80GHZ 2GB RAM T4-D13
$200.0
HOSPITAL COMPUTER TOUCH SCREEN INTEL ATOM D525 @ 1.80GHZ 2GB RAM T4-D13 picture1x MM5290J-4 National Semiconductor ram ceramic CDIP-16
$3.5
1x MM5290J-4 National Semiconductor ram ceramic CDIP-16 pictureENERPAC RCH-1003 100 TON HOLLOW RAM HYDRAULIC CYLINDER #1
$1749.99
ENERPAC RCH-1003 100 TON HOLLOW RAM HYDRAULIC CYLINDER #1 pictureHotSauce HS-2900 15" Touchscreen POS Terminal Intel Atom D525 1GB RAM 160GB HD
$9.99
HotSauce HS-2900 15






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