Post buffer lost

Hi Everyone,

I am working on an enterprise application and I have the following problem.

I have a thread called dispatcher which will send the request to the server and process the response and pass it to the main thread to display on the screen. My problem is that, 1 out of 15 times of my 'Post Request', my Post parameters gets lost and the server returns an error. This happens in motorola iden 866 phones. I tried on Sun WTK 2.2 and I did not get any error. I did not get a chance to try on other phones as of now.

I did some work around by ,

Adding the Post parameters on the header and I can see them in the log files of my server when this error occurs.

Adding the content length but no effect.

The strange thing is that there is no particular sequence to reproduce the error. It happens irregularly. Also to let you know that this is tested only on motorola IDEN 866 phones till now. The Sun WTK 2.2 emulator which is on windows xp does not show this error.

Any help is really appreciated as this is bugging me for a month now.

Thank you all,

Pradeep.

Message was edited by:

deep_k

Message was edited by:

deep_k

[1212 byte] By [deep_ka] at [2007-11-27 4:33:21]
# 1
Can you post the relative code?
PeppeMEa at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

/********************************************************************************

Open the connection

*********************************************************************************/

postBuffer = null;

String reqBuffer;

// request uri is of the form https://xyz.com?abc=1

int index = requestURI.toString().indexOf('?');

if (index != -1) {

//

// we have form variables

// - the post buffer is everything after '?'

// - remove everything after '?' and append session id for request buffer

//

postBuffer = requestURI.toString().substring(index + 1);

requestURI.setLength(index);

}

reqBuffer = requestURI.toString();

fiwConnection = (HttpConnection) Connector.open(reqBuffer);

if (fiwConnection == null)

return null;

fiwConnection.setRequestMethod(HttpConnection.POST);

fiwConnection.setRequestProperty("user-agent",UIConstants.USER_AGENT);

if(postBuffer != null && postBuffer.length() > 0)

fiwConnection.setRequestProperty("user-data", postBuffer);

fiwConnection.setRequestProperty("x-up-uplink",UIConstants.NETWORK);

fiwConnection.setRequestProperty("Accept","*/*");

if(deviceIdCookie != null && deviceIdCookie.length() > 0){

fiwConnection.setRequestProperty("cookie",deviceIdCookie);

}

/********************************************************************

Write post buffer data into Output Stream of fiw connection

*********************************************************************/

if (postBuffer != null) {

data=postBuffer.getBytes();

//

// tell the server that the form variables are urlencoded in the post buffer

//

fiwConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

//

// create the post buffer

//

_os = fiwConnection.openOutputStream();

_os.write(data);

_os.close();

_os=null;

} else {

Log.log("POST buffer is empty");

}

/**************************************************************************

Get the Response from the server

***************************************************************************/

if ((responseCode=fiwConnection.getResponseCode()) == HttpConnection.HTTP_OK) {

_is = fiwConnection.openInputStream();

int responseLen = (int) fiwConnection.getLength();

if (responseLen != -1) {

response = new byte[responseLen];

_is.read(response);

} else {

ByteArrayOutputStream byteStream = new ByteArrayOutputStream();

byte buffer[] = new byte[BUF_LEN];

int len = 0;

while ((len = _is.read(buffer)) != -1) {

byteStream.write(buffer, 0, len);}

}

response = byteStream.toByteArray();

}

_is.close();

_is=null;

}

deep_ka at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
The code seems ok, I have no idea about cause of the problem.Have you see if you kvm device have a bug?
PeppeMEa at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
How do i know if the KVM device has the bug?By the way, this is tested on a couple of Motorola IDEN 866 devices and all of them has this bug.
deep_ka at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
Is there anyone who could help me out here. Its been giving me a hard time to figure out.
deep_ka at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6

Some devices have a maximum length for the request method. Maybe this could be causing the "bug". Your should always rely on the documentation

for each device. You could check this link, search for iDEN there:

http://developer.motorola.com/technologies/java/devguides/

Hope this helps.

Danniel_Williana at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7

well actually the request is having one parameter and the number of characters is around 10 characters for which I see the error.

Also to remind you that this is not a consistent error. For the same request it gives me results but approximately out of 15 times you will see this error once.

deep_ka at 2007-7-12 9:43:11 > top of Java-index,Java Mobility Forums,Java ME Technologies...