10-08-2009 08:18 AM
I have been encountering different behavior for the phone networks when using the the POST method on and http connection. Some networks work flawlessly, other networks seem to kill the connection after 1200 bytes have been transferred.
Has anyone encountered this anomaly ?
Is there a work around ??
10-08-2009 08:30 AM
10-08-2009 09:19 AM
The provider is Nextel
connection is typical
//==============
hc = (HttpConnection) Connector.open("http://urlString", Connector.READ_WRITE, true);
// Set the request method and headers
hc.setRequestMethod(HttpConnection.POST);
hc.setRequestProperty("Content-Language", "en-US");
hc.setRequestProperty("Content-Length", Integer.toString(postString.length()));
hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
dos = new DataOutputStream(hc.openOutputStream());
byte outByte[] = PostString.getBytes();
dos.write(outByte,0, PostString.length());
int rc = hc.getResponseCode();
//================
The PostString is encoded via URLEncodedPostData.
I have snt the data via several networks, Sprint, Verizon and ATT. Only Nextel causes a problem. I worte a java SE app and ran the same data via POST from a SE Java app and had no issues.
I tried using flush() but the API docs say that getResponseCode flush the output so that has had no effect. The connection seems to break when the data length reaches 1208 bytes. I tried breaking the data into chunks thinking it might be a packet size. That had no effect. Is there any way to control the connection timeout other than the boolean timeout exception flag in the inital connection. This did not help.
I have been deploying apps on Blackberry's for 5 years and phones for 10 years. This is really odd
10-08-2009 04:10 PM
Try setting the user agent for the request. I don't know about Nextel, but I've seen weird behavior on some carriers for http requests with no user agent header.
Also, do you know if the failure depends only on the data length, or might it also depend on the data content?
As an aside: to write bytes, you don't need a DataOutputStream; you can directly use the OutputStream returned by hc.openOutputStream(). If you need a DataOutputStream for some other reason, it's better to call hc.openDataOutputStream() rather than wrapping hc.openOutputStream in your own code. The way you are doing it, the connection won't flush the correct stream. I think DataOutputStream just passes byte array writes directly to the underlying OutputStream, but if it did buffer the data, the code as written has a good chance of failing for that reason.
10-08-2009 04:38 PM
It appears to be only length. The content is encoded as URLEncodedPostData. I have bb's running on several networks only iDen (Nextel) is a problem. I had seen in Forums that the httpConnection.getResponseCode() flushed the connection and that the connection should only be flushed once. I initially used OutputStream. I'll give that another look.
The odd thing is this is only a problem on iDen.
I have not found any info on other conneciton settings for iDen other than it does not use APN's in the connection string.
I also noticed that if I added ";deviceside=true " to the connection string I got an "invalid url" response